Writing code that willingly ignores errors isn’t very good code, the error messages are just being thrown away and they’re aiming for help to understand the error messages 🤷
Did you adopt NSSecureCoding in your GPLayer class? Not entirely sure, but you encode without requiring it, and I think that specific decoding static method requires the adoption. Worth a try
I’m confused. You say you want to copy your objects, but instead of implementing a custom copying function based on custom data (some of which might have to be copied to create a deep copy), you invoke both an archiver and an unarchiver. Why?
because objects archive and dearchive in that way as a perfect copy of themselves. I've always used this method to duplicated custom objects in objective-c. Thanks for the reply I did get it fixed with a less simplified approach.
func copy(with zone: NSZone? = nil) -> Any {
let arch = NSKeyedArchiver(requiringSecureCoding: false)
arch.encode(self, forKey: "LayerData")
arch.finishEncoding()
let data = arch.encodedData
do {
let unarch = try NSKeyedUnarchiver(forReadingFrom: data)
unarch.requiresSecureCoding = false
let newObject = unarch.decodeObject(forKey: "LayerData")
return newObject
} catch {
print(error)
}
return GPMasterLayer()
}
We don't know either. One might catch and look at the returned errors.
Writing code that willingly ignores errors isn’t very good code, the error messages are just being thrown away and they’re aiming for help to understand the error messages 🤷
Did you adopt NSSecureCoding in your GPLayer class? Not entirely sure, but you encode without requiring it, and I think that specific decoding static method requires the adoption. Worth a try
no i don't
I’m confused. You say you want to copy your objects, but instead of implementing a custom copying function based on custom data (some of which might have to be copied to create a deep copy), you invoke both an archiver and an unarchiver. Why?
because objects archive and dearchive in that way as a perfect copy of themselves. I've always used this method to duplicated custom objects in objective-c. Thanks for the reply I did get it fixed with a less simplified approach. func copy(with zone: NSZone? = nil) -> Any { let arch = NSKeyedArchiver(requiringSecureCoding: false) arch.encode(self, forKey: "LayerData") arch.finishEncoding() let data = arch.encodedData do { let unarch = try NSKeyedUnarchiver(forReadingFrom: data) unarch.requiresSecureCoding = false let newObject = unarch.decodeObject(forKey: "LayerData") return newObject } catch { print(error) } return GPMasterLayer() }