EOEditingContext Delegate
(informal protocol)
Declared in:
- EOControl/EOEditingContext.h
Protocol Description
The EOEditingContext Delegate informal protocol defines methods that an EOEditingContext can invoke in its delegate. Delegates are not required to provide implementations for all of the methods in the informal protocol. Instead, declare and implement any subset of the methods declared in the informal protocol that you need, and use the EOEditingContext method setDelegate: method to assign your object as the delegate. An editing context can determine if the delegate doesn't implement a delegate method and only attempts to invoke the methods the delegate actually implements.
Method Types
- Fetching objects
- - editingContext:shouldFetchObjectsDescribedByFetchSpecification:
- Invalidating objects
- - editingContext:shouldInvalidateObject:globalID:
- Saving changes
- - editingContextWillSaveChanges:
- Handling failures
- - editingContextShouldValidateChanges:
- - editingContext:shouldPresentException:
- - editingContextShouldUndoUserActionsAfterFailure:
- Merging changes
- - editingContext:shouldMergeChangesForObject:
- - editingContextDidMergeChanges:
Instance Methods
editingContextDidMergeChanges:
- (void)editingContextDidMergeChanges:(EOEditingContext
*)anEditingContext
Invoked once after a batch of objects has been updated in anEditingContext's parent object store (in response to an EOObjectsChangedInStoreNotification). A delegate might implement this method to define custom merging behavior, most likely in conjunction with editingContext:shouldMergeChangesForObject:. It is safe for this method to make changes to the objects in the editing context.
editingContext:shouldFetchObjectsDescribedByFetchSpecification:
- (NSArray *)editingContext:(EOEditingContext
*)editingContext
shouldFetchObjectsDescribedByFetchSpecification:(EOFetchSpecification
*)fetchSpecification
editingContext:shouldInvalidateObject:globalID:
- (BOOL)editingContext:(EOEditingContext
*)anEditingContext
shouldInvalidateObject:(id)object
globalID:(EOGlobalID *)globalID
Sent when an object identified by globalID has been explicitly invalidated. If the delegate returns NO, the invalidation is refused. This allows the delegate to selectively override object invalidations.
See Also: - invalidateAllObjects, - revert
editingContext:shouldMergeChangesForObject:
- (BOOL)editingContext:(EOEditingContext
*)anEditingContext
shouldMergeChangesForObject:(id)object
When an EOObjectsChangedInStoreNotification is received, anEditingContext invokes this method in its delegate once for each of the objects that has both uncommitted changes and an update from the EOObjectStore. This method is invoked before any updates actually occur.
If this method returns YES, all of the uncommitted changes should be merged into the object after the update is applied, in effect preserving the uncommitted changes (the default behavior). The delegate method editingContext:shouldInvalidateObject:globalID: will not be sent for the object in question.
If this method returns NO, no uncommitted changes are applied. Thus, the object is updated to reflect the values from the database exactly. This method should not make any changes to the object since it is about to be invalidated.
If you want to provide custom merging behavior, you need to implement both this method and editingContextDidMergeChanges:. You use editingContext:shouldMergeChangesForObject: to save information about each changed object and return YES to allow merging to continue. After the default merging behavior occurs, editingContextDidMergeChanges: is invoked, at which point you implement your custom behavior.
editingContext:shouldPresentException:
- (BOOL)editingContext:(EOEditingContext
*)anEditingContext
shouldPresentException:(NSException
*)exception
See Also: - messageHandler
editingContextShouldUndoUserActionsAfterFailure:
- (BOOL)editingContextShouldUndoUserActionsAfterFailure:(EOEditingContext
*)anEditingContext
Sent when a validation error occurs while processing a processRecentChanges message. If the delegate returns NO, it disables the automatic undoing of user actions after validation has resulted in an error.
By default, if a user attempts to perform an action that results in a validation failure (such as deleting a department object that has a delete rule stating that the department can't be deleted if it contains employees), the user's action is immediately rolled back. However, if this delegate method returns NO, the user action is allowed to stand (though attempting to save the changes to the database without solving the validation error will still result in a failure). Returning NO gives the user an opportunity to correct the validation problem so that the operation can proceed (for example, the user might delete all of the department's employees so that the department itself can be deleted).
editingContextShouldValidateChanges:
- (BOOL)editingContextShouldValidateChanges:(EOEditingContext
*)anEditingContext
editingContextWillSaveChanges:
- (void)editingContextWillSaveChanges:(EOEditingContext
*)editingContext