Instance Method


Converts to permanent IDs the object IDs of the objects in a given array.


- (BOOL)obtainPermanentIDsForObjects:(NSArray<NSManagedObject *> *)objects error:(NSError * _Nullable *)error;



An array of managed objects.


If an error occurs, upon return contains an NSError object that describes the problem.

Return Value

YES if permanent IDs are obtained for all the objects in objects, otherwise NO.


This method converts the object ID of each managed object in objects to a permanent ID. Although the object will have a permanent ID, it will still respond positively to inserted until it is saved. Any object that already has a permanent ID is ignored.

Any object not already assigned to a store is assigned based on the same rules Core Data uses for assignment during a save operation (first writable store supporting the entity, and appropriate for the instance and its related items).

Special Considerations

This method results in a transaction with the underlying store which changes the file’s modification date.

In macOS, this results an additional consideration if you invoke this method on the managed object context associated with an instance of NSPersistentDocument. Instances of NSDocument need to know that they are in sync with the underlying content. To avoid problems, after invoking this method you must therefore update the document’s modification date (using fileModificationDate).

See Also

Managing Managed Objects


A Boolean value that indicates the behavior of inaccessible faults.


The set of objects that have been inserted into the context but not yet saved in a persistent store.


The set of objects registered with the context that have uncommitted changes.


The set of objects that will be removed from their persistent store during the next save operation.

- insertObject:

Registers an object to be inserted in the context’s persistent store the next time changes are saved.

- deleteObject:

Specifies an object that should be removed from its persistent store when changes are committed.

- assignObject:toPersistentStore:

Specifies the store in which a newly inserted object will be saved.

- detectConflictsForObject:

Marks an object for conflict detection.

- refreshObject:mergeChanges:

Updates the persistent properties of a managed object to use the latest values from the persistent store.

- processPendingChanges

Forces the context to process changes to the object graph.

- observeValueForKeyPath:ofObject:change:context:

Allows a context that has registered as an observer of a value to be notified of a change to that value.