更新时间:2022-05-31 22:14:26
在几个用户的帮助和一些额外搜索的帮助下,我能够找出问题的原因。
With the help of a couple of users and some added searching, I was able to figure out the cause of my problem.
根据前面提到的用户的建议,我将 NSCoding
协议添加到我的 CalendarEvent
类。
Per the suggestion of the previously mentioned users, I added the NSCoding
protocol to my CalendarEvent
class.
class CalendarEvent : NSObject, NSCoding {
....
}
不幸的是,这并没有完全解决问题,但这是一个开始。一些错误和快速搜索显示我必须更改此内容:
Unfortunately, that didn't completely fix the issue, but it was a start. A few errors and a quick search showed me that I had to change this:
init(withCoder coder : NSCoder){
....
}
func encodeWithCoder(coder : NSCoder){
....
}
到此:
required init(coder : NSCoder) {
....
}
func encode(with aCoder : NSCoder) {
....
}
进行这些更改后,我的代码运行得非常好。
After making those changes, my code ran perfectly fine.