【问题标题】:CoreData error with setter method使用setter方法的CoreData错误
【发布时间】:2015-08-03 18:10:58
【问题描述】:

我收到了这个令人讨厌的崩溃错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Match setParentGameID:]: unrecognized selector sent to instance 0x7972d710'

所以我想要么我正在尝试为不存在的键设置一个值,要么我在某处使用了无效值。我检查了我的文件,我为 Match 对象设置 parentGameID 的唯一地方是这一行:

Match.createInManagedObjectContext(self.managedObjectContext!, date: "12/12/12", parentID: g.id)

其中 g.id 是一个字符串值。我的 Match 类如下所示:

class Match: NSManagedObject {

@NSManaged var date: String
@NSManaged var id: String
@NSManaged var parentGameID: String

class func createInManagedObjectContext(moc: NSManagedObjectContext, date: String, parentID: String) -> Match {
        let newItem = NSEntityDescription.insertNewObjectForEntityForName("Match", inManagedObjectContext: moc) as! Match
        newItem.date = date
        newItem.id = NSUUID().UUIDString
        newItem.parentGameID = parentID

        return newItem
    }

}

有什么想法吗?

【问题讨论】:

标签: ios swift core-data


【解决方案1】:

原来我忘记更改我的一个数据模型以反映在第一个模型中所做的更改。添加了需要的属性,我的代码运行良好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-25
    • 1970-01-01
    • 2014-01-27
    • 1970-01-01
    • 2015-07-23
    • 2018-08-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多