I have seen several questions similar to mine; however, those are pertaining to swift 2/1 and I am currently using swift 3. I believe Apple has changed it slightly.
class Person: NSObject, NSCoding {
var signature: UIImage
init(signature: UIImage) {
self.signature = signature
}
required convenience init(coder aDecoder: NSCoder) {
let signature = aDecoder.decodeObject(forKey: "signature") as! UIImage
self.init(signature: signature)
}
func encodeWithCoder(aCoder: NSCoder) {
aCoder.encode(signature, forKey: "signature")
}
}
You will notice how Swift 3 now forces me to use required convenience init(
instead of required init(
. Perhaps that has something to do with it.
How can I resolve this issue? Thanks!
The
encode
method in Swift 3 has been renamed toWhen you get the do not conform error you can easily find out which required methods are missing