I’m developing an application that uses multiple threads to do some intensive calculations as well as fetch a good size of data. Thus, I’m trying to be a good little developer and adhere to Apple’s concurrency guidelines when designing my application with CoreData. Basically, I have an NSOperation that runs and fetches the data. It returns (to a method in the main thread) an NSMutableSet that contains an NSManagedObjectID for each of the entities returned.
Here is the method in the main thread where I want to convert those NSManagedObjectIDs to actual NSManagedObject subclasses again:
-(void)updateLocalContextWithObjectIDs:(NSMutableSet *)idSet {
NSMutableSet *entitySet = [[NSMutableSet alloc] init];
for (NSManagedObjectID *objectID in idSet) {
[entitySet addObject: (Person *)[[self.dataProvider sharedManagedObjectContext] objectWithID:objectID]];
}
self.entitySet = entitySet;
[entitySet release];
}
The problem I’m having is that I’m getting the following error when this loop runs:
-[Person persistentStore]: unrecognized selector sent to instance 0x619b270
Any ideas why this is happening? Calling persistentStore on the Person object isn’t being done by me—it must be happening within CoreData and I’m not doing something correctly.
Thanks in advance.
The issue was that I was passing in a set of
NSManagedObjects instead of the set ofNSManagedObjectIDs like I should’ve been.This is solved.