Instance Method


Attempts to commit unsaved changes to registered objects to the context’s parent store.


- (BOOL)save:(NSError * _Nullable *)error;



A pointer to an NSError object. You do not need to create an NSError object. The save operation aborts after the first failure if you pass NULL.

Return Value

YES if the save succeeds, otherwise NO.


If there were multiple errors (for example several edited objects had validation failures) the description of NSError returned indicates that there were multiple errors, and its userInfo dictionary contains the key NSDetailedErrors. The value associated with the NSDetailedErrors key is an array that contains the individual NSError objects.

If a context’s parent store is a persistent store coordinator, then changes are committed to the external store. If a context’s parent store is another managed object context, then save: only updates managed objects in that parent store. To commit changes to the external store, you must save changes in the chain of contexts up to and including the context whose parent is the persistent store coordinator.

See Also

Managing Unsaved and Uncommitted Changes


A Boolean value that indicates whether the context has uncommitted changes.