Instance Method

didSave

Provides an opportunity to add code into the life cycle of the managed object after the managed object’s context completes a save operation.

Declaration

- (void)didSave;

Discussion

You can use this method to notify other objects after a save, and to compute transient values from persistent values.

This method can have “side effects” on the persistent values, however any changes you make using standard accessor methods will by default dirty the managed object context and leave your context with unsaved changes. Moreover, if the object’s context has an undo manager, such changes will add an undo operation. For document-based applications, changes made in didSave will therefore come into the next undo grouping, which can lead to “empty” undo operations from the user's perspective. You may want to disable undo registration to avoid this issue.

The sense of “save” in the method name is that of a database commit statement and so applies to deletions as well as to updates to objects. For subclasses, this method is therefore an appropriate locus for code to be executed when an object deleted as well as “saved to disk.” You can find out if an object is marked for deletion with deleted.

Special Considerations

You cannot attempt to resurrect a deleted object in didSave.

See Also

Managing Change Events

contextShouldIgnoreUnmodeledPropertyChanges

A Boolean value that indicates whether instances of the class should be marked as having changes if an unmodeled property is changed.

- awakeFromFetch

Provides an opportunity to add code into the life cycle of the managed object when it is being fulfilled from a fault.

- awakeFromInsert

Provides an opportunity to add code into the life cycle of the managed object when it is initially created.

- awakeFromSnapshotEvents:

Provides an opportunity to add code into the life cycle of the managed object when it is being fulfilled from a snapshot.

- changedValues

Returns a dictionary containing the keys and (old) values of persistent properties that have been changed since the last fetching or saving of the managed object.

- changedValuesForCurrentEvent

Returns a dictionary containing the keys and old values of persistent properties that have changed since the last posting of NSManagedObjectContextObjectsDidChangeNotification.

- committedValuesForKeys:

Returns a dictionary of the last fetched or saved values of the managed object for the properties specified by the given keys.

- prepareForDeletion

Provides an opportunity to add code into the life cycle of the managed object when it is about to be deleted.

- willSave

Provides an opportunity to add code into the life cycle of the managed object when it is about to be saved.

- willTurnIntoFault

Provides an opportunity to add code into the life cycle of the managed object before it is converted to a fault.

- didTurnIntoFault

Provides an opportunity to add code into the life cycle of the managed object when it is turned into a fault.

+ fetchRequest

Returns a new fetch request initialized with the entity represented by this subclass.