【发布时间】:2016-07-31 11:12:42
【问题描述】:
我正在尝试通过SymSpell实现自动更正
我已经在容器应用程序中创建了字典,应该保存它并从键盘扩展中读取它
字典包含一个dictionaryItem对象,需要被NSCoder序列化才能保存
我尝试将方法添加到对象,但出现错误“init(coder adecoder nscoder) swift cannot be sent to an abstract object of class NSCoder”
required init(coder aDecoder: NSCoder) {
if let suggestions = aDecoder.decodeObjectForKey("suggestions") as? [Int] {
self.suggestions = suggestions
}
if let count = aDecoder.decodeObjectForKey("count") as? Int {
self.count = count
}
}
func encodeWithCoder(aCoder: NSCoder) {
if let count = self.count as? Int {
aCoder.encodeObject(count, forKey: "count")
}
if let suggestions = self.suggestions as? [Int] {
aCoder.encodeObject(suggestions, forKey: "suggestions")
}
}
任何想法如何解决这个问题?
【问题讨论】:
标签: ios swift custom-keyboard