我为iOS创建了一个静态库。该库使用核心数据来存储从互联网获取的一些对象。 当我尝试在标准iOS项目中使用我的库时,似乎无法创建核心数据实体的任何实例。我有以下错误:
-[NSManagedObject initWithDictionary:]: unrecognized selector sent to instance 0x6e5d4e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject initWithDictionary:]: unrecognized selector sent to instance 0x6e5d4e0'
initWithDictionary实际上是我在核心数据实体对象上调用的方法。
然后我尝试从库中创建托管对象模型,如下所示:core data in a static library for the iPhone
NSMutableSet *allBundles = [[[NSMutableSet alloc] init] autorelease];
[allBundles addObjectsFromArray: [NSBundle allBundles]];
[allBundles addObjectsFromArray: [NSBundle allFrameworks]];
managedObjectModel = [NSManagedObjectModel mergedModelFromBundles: [allBundles allObjects]];
OR
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Model" withExtension:@"momd"];
managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
但它不起作用。当我尝试实例化我的库的类,给它管理对象模型时,我有以下错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LauncherViewController initWithNibName:managedObjectModel:andKey:]: unrecognized selector sent to instance 0x6b94db0'
如果我试试这个:core data in a static library for the iPhone,我会收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
请帮助我,我真的不知道该怎么做......