1

I created a static library for iOS. The library uses core data to store some objects fetched from the internet. When I try to use my library in a standard iOS project, it seems like it can't create any instances of core data entities. I have the following error :

-[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 is actually a method I call on a core data entity object.

Then I tried to create the managed object model out of the library like shown here : 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]; 

but it didn't work. I have the following error when I try to instantiate a class of my library giving it the managed object model :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LauncherViewController initWithNibName:managedObjectModel:andKey:]: unrecognized selector sent to instance 0x6b94db0'

If I try this : core data in a static library for the iPhone , I get this error :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

Please help me, I really don't know what to do anymore...

Community
  • 1
  • 1
Alexis
  • 16,629
  • 17
  • 62
  • 107

0 Answers0