| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in Mac OS X v10.4 and later. |
| Companion guide | |
| Declared in | NSManagedObjectID.h |
| Related sample code |
An NSManagedObjectID object is a compact, universal, identifier for a managed object. This forms the basis for uniquing in the Core Data Framework. A managed object ID uniquely identifies the same managed object both between managed object contexts in a single application, and in multiple applications (as in distributed systems). Identifiers contain the information needed to exactly describe an object in a persistent store (like the primary key in the database), although the detailed information is not exposed. The framework completely encapsulates the “external” information and presents a clean object oriented interface.
Object IDs can be transformed into a URI representation which can be archived and recreated later to refer back to a given object (using managedObjectIDForURIRepresentation: (NSPersistentStoreCoordinator) and objectWithID: (NSManagedObjectContext). For example, the last selected group in an application could be stored in the user defaults through the group object’s ID. You can also use object ID URI representations to store “weak” relationships across persistent stores (where no hard join is possible).
Returns the entity description associated with the receiver.
- (NSEntityDescription *)entity
The entity description object associated with the receiver
entity (NSManagedObject)NSManagedObjectID.hReturns a Boolean value that indicates whether the receiver is temporary.
- (BOOL)isTemporaryID
YES if the receiver is temporary, otherwise NO.
Most object IDs return NO. New objects inserted into a managed object context are assigned a temporary ID which is replaced with a permanent one once the object gets saved to a persistent store.
NSManagedObjectID.hReturns the persistent store that contains the object whose ID is the receiver.
- (NSPersistentStore *)persistentStore
The persistent store that contains the object whose ID is the receiver, or nil if the ID is for a newly-inserted object that has not yet been saved to a persistent store.
NSManagedObjectID.hReturns a URI that provides an archiveable reference to the object which the receiver represents.
- (NSURL *)URIRepresentation
An NSURL object containing a URI that provides an archiveable reference to the object which the receiver represents.
If the corresponding managed object has not yet been saved, the object ID (and hence URI) is a temporary value that will change when the corresponding managed object is saved.
managedObjectIDForURIRepresentation: (NSPersistentStoreCoordinator)objectWithID:: (NSManagedObjectContext)NSManagedObjectID.hLast updated: 2009-05-01