Next Page > Hide TOC

NSEditor Protocol Reference

(informal protocol)

Adopted by
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.3 and later.
Companion guide
Declared in
NSKeyValueBinding.h

Overview

The NSEditor informal protocol is implemented by controllers and user interface elements. It provides a means for requesting that the receiver commit or discard any pending edits.

These methods are typically invoked on user interface elements by a controller. They can also be sent to a controller in response to a user’s attempt to save a document or quit an application.

NSController provides an implementation of this protocol, as do the Application Kit user interface elements that support binding.

Tasks

Managing Editing

Instance Methods

commitEditing

Returns whether the receiver was able to commit any pending edits.

- (BOOL)commitEditing

Discussion

Returns YES if the changes were successfully applied to the model, NO otherwise. A commit is denied if the receiver fails to apply the changes to the model object, perhaps due to a validation error.

Availability
See Also
Related Sample Code
Declared In
NSKeyValueBinding.h

commitEditingWithDelegate:didCommitSelector:contextInfo:

Attempt to commit any currently edited results of the receiver.

- (void)commitEditingWithDelegate:(id)delegate didCommitSelector:(SEL)didCommitSelector contextInfo:(void *)contextInfo

Discussion

The receiver must have been registered as the editor of an object using objectDidBeginEditing:, and has not yet been unregistered by a subsequent invocation of objectDidEndEditing:. When the committing has either succeeded or failed, send the following message to the specified object. The didCommitSelector method must have the following method signature:

- (void)editor:(id)editor didCommit:(BOOL)didCommit contextInfo:(void *)contextInfo

If an error occurs while attempting to commit, for example if key-value coding validation fails, an implementation of this method should typically send the NSView in which editing is being done a presentError:modalForWindow:delegate:didRecoverSelector:contextInfo: message, specifying the view's containing window.

Availability
Related Sample Code
Declared In
NSKeyValueBinding.h

discardEditing

Causes the receiver to discard any changes, restoring the previous values.

- (void)discardEditing

Availability
See Also
Declared In
NSKeyValueBinding.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.