Instance Property


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


@property(nonatomic, readonly) BOOL hasChanges;


If you are observing this property using key-value observing (KVO) you should not touch the context or its objects within your implementation of observeValueForKeyPath:ofObject:change:context: for this notification. (This is because of the intricacy of the locations of the KVO notifications—for example, the context may be in the middle of an undo operation, or repairing a merge conflict.) If you need to send messages to the context or change any of its managed objects as a result of a change to the value of hasChanges, you must do so after the call stack unwinds (typically using performSelector:withObject:afterDelay: or a similar method).

Special Considerations

In macOS 10.6 and later, this property is Key-value observing compliant.

See Also

Managing Unsaved and Uncommitted Changes

- save:

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