I want to make sure that an NSManagedObject that I am working with has a permanent NSManagedObjectID. I know that it only is made permanent on [NSManagedObjectContext save:] or [NSManagedObjectContext obtainPermanentIDsForObjects:error:]. However, before I save the context to get a permanent ID, is there a way to determine if an object has a permanent ID or not? That way I don't needlessly save the store.
1 Answers
6
votes
NSManagedObjectID has a isTemporaryID method that indicates whether the object ID is temporary, so you can check
BOOL isTemporary = [[myObject objectID] isTemporaryID];
However, I would just call obtainPermanentIDsForObjects for the objects in question because I assume that this does not cause additional overhead if the object IDs are already permanent.