更新时间:2023-10-22 08:18:22
该错误消息具有误导性,但是您需要将init(coder:)
设置为指定的初始化程序.
The error message is sort of misleading, but you need to make init(coder:)
a designated initializer.
您需要将init(code:)
修改为以下内容:
You need to modify your init(code:)
to something like this:
required init?(coder aDecoder: NSCoder) {
guard let unarchivedId = aDecoder.decodeObjectForKey("id") as? Int else {
return nil
}
self.id = unarchivedId
super.init()
}