最佳答案
I can easily get an object's ID in Core Data using the following code:
NSManagedObjectID *moID = [managedObject objectID];
However, is there a way to get an object out of the core data store by giving it a specific object ID? I know that I can do this by using an NSFetchRequest, like this:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Document" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(objectID = %@)", myObjectID];
[fetchRequest setPredicate:predicate];
However, I'd like to do it in a way that does not initiate its own fetch request. Any ideas?