NSManagedObjectID Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in iOS 3.0 and later. |
| Companion guide | |
| Declared in | NSManagedObjectID.h |
Overview
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).
Instance Methods
entity
Returns the entity description associated with the receiver.
Return Value
The entity description object associated with the receiver
Availability
- Available in iOS 3.0 and later.
See Also
-
entity(NSManagedObject)
Declared In
NSManagedObjectID.hisTemporaryID
Returns a Boolean value that indicates whether the receiver is temporary.
Return Value
YES if the receiver is temporary, otherwise NO.
Discussion
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.
Availability
- Available in iOS 3.0 and later.
Declared In
NSManagedObjectID.hpersistentStore
Returns the persistent store that contains the object whose ID is the receiver.
Return Value
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.
Availability
- Available in iOS 3.0 and later.
Declared In
NSManagedObjectID.hURIRepresentation
Returns a URI that provides an archiveable reference to the object which the receiver represents.
Return Value
An NSURL object containing a URI that provides an archiveable reference to the object which the receiver represents.
Discussion
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.
Availability
- Available in iOS 3.0 and later.
See Also
-
managedObjectIDForURIRepresentation:(NSPersistentStoreCoordinator) -
objectWithID:: (NSManagedObjectContext)
Declared In
NSManagedObjectID.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-05-01)