Class

NSManagedObjectID

A compact, universal identifier for a managed object.

Overview

This identifier 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 managedObjectID(forURIRepresentation:) (NSPersistentStoreCoordinator) and object(with:) (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).

Topics

Getting Managed Object ID Information

var entity: NSEntityDescription

The entity description associated with the object ID.

var isTemporaryID: Bool

A Boolean value that indicates whether the object ID is temporary.

var persistentStore: NSPersistentStore?

The persistent store that fetched the object for the object ID.

func uriRepresentation()

Returns a URI that provides an archiveable reference to the object for the object ID.

See Also

Inspecting Entities and Configurations

var entities: [NSEntityDescription]

The entities in the model.

var entitiesByName: [String : NSEntityDescription]

The entities of the model, keyed by name.

var configurations: [String]

All the available configuration names of the model.

func entities(forConfigurationName: String?)

Returns the entities of the model for a specified configuration.

func setEntities([NSEntityDescription], forConfigurationName: String)

Associates the specified entities with the model using the given configuration name.

class NSEntityDescription

A description of an entity in Core Data.

class NSAttributeDescription

A description of the attributes of an entity described by an instance of NSEntityDescription.

class NSPropertyDescription

A description of the properties of an entity in a Core Data managed object model.

class NSRelationshipDescription

A description of the relationships of an entity in an NSEntityDescription object.