Instance Method


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


- (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag;



A managed object.


A Boolean value.

If flag is NO, then object is turned into a fault and any pending changes are lost. The object remains a fault until it is accessed again, at which time its property values will be reloaded from the store or last cached state.

If flag is YES, then object is turned into a fault and object’s property values are reloaded from the values from the store or the last cached state then any changes that were made (in the local context) are re-applied over those (now newly updated) values. (If flag is YES the merge of the values into object will always succeed—in this case there is therefore no such thing as a “merge conflict” or a merge that is not possible.)


If the staleness interval (see stalenessInterval) has not been exceeded, any available cached data is reused instead of executing a new fetch. If flag is YES, this method does not affect any transient properties; if flag is NO, transient properties are disposed of.

You typically use this method to ensure data freshness if more than one managed object context may use the same persistent store simultaneously, in particular if you get an optimistic locking failure when attempting to save.

Turning object into a fault (flag is NO) means that strong references to related managed objects (that is, those to which object has a reference) are broken, so you can also use this method to trim a portion of your object graph you want to constrain memory usage.

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.

- obtainPermanentIDsForObjects:error:

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

- detectConflictsForObject:

Marks an object for conflict detection.

- 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.