1
我的应用程序是一个典型的基于非文档的核心数据应用程序。我没有修改任何预先提供的项目代码,并且一直使用Xcode默认提供的AppDelegate文件(该项目不够大,不足以保证更多)。manageObjectContext抛出无法识别的选择器错误?
现在,当我尝试将项目添加到我的核心数据存储之一,
NSManagedObject *colorItemObject = [NSEntityDescription insertNewObjectForEntityForName:@"ColorItem" inManagedObjectContext: [NSApp managedObjectContext]];
[colorItemObject setValue:[colorSetsArrayController valueForKeyPath:@"selection.colorSetName"] forKey:@"parent"];
它抛出一个无法识别的选择异常:出现
-[_NSStateMarker managedObjectContext]: unrecognized selector sent to instance 0x100118290
类似的错误,使用[自managedObjectContext ]。什么可能导致这个?
感谢您的回复,但我也尝试过[[NSApp委托] managedObjectContext]和[self manageObjectContext]。它们都可以在没有任何警告的情况下编译好,但会在运行时抛出错误 –
它会抛出什么错误? – Yuji
[self managedObjectContext]与上面相同,即 - [_NSStateMarker managedObjectContext]:发送到实例0x100118290的无法识别的选择器。 [[NSApp委托] managedObjectContext]也一样。 –