NSController Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.3 and later. |
| Companion guide | |
| Declared in | NSController.h |
Overview
NSController is an abstract class that implements the NSEditor and NSEditorRegistration informal protocols required for controller classes.
Adopted Protocols
Instance Methods
commitEditing
Causes the receiver to attempt to commit any pending edits, returning YES if successful or no edits were pending.
Discussion
The receiver invokes commitEditing on any current editors, returning their response. A commit is denied if the receiver fails to apply the changes to the model object, perhaps due to a validation error.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSController.hcommitEditingWithDelegate:didCommitSelector:contextInfo:
Attempts to commit any pending changes in known editors of the receiver.
Parameters
- delegate
An object that can serve as the receiver's delegate. It should implement the method specified by didCommitSelector.
- didCommitSelector
A selector that is invoked on delegate. The method specified by the selector must have the same signature as the following method:
- (void)editor:(id)editor didCommit:(BOOL)didCommit contextInfo:(void *)contextInfo
- contextInfo
Contextual information that is sent as the
contextInfoargument to delegate when didCommitSelector is invoked.
Discussion
Provides support for the NSEditor informal protocol. This method attempts to commit pending changes in known editors. Known editors are either instances of a subclass of NSController or (more rarely) user interface controls that may contain pending edits—such as text fields—that registered with the context using objectDidBeginEditing: and have not yet unregistered using a subsequent invocation of objectDidEndEditing:.
The receiver iterates through the array of its known editors and invokes commitEditing on each. The receiver then sends the message specified by the didCommitSelector selector to the specified delegate.
The didCommit argument is the value returned by the editor specified by editor from the commitEditing message. The contextInfo argument is the same value specified as the contextInfo parameter—you may use this value however you wish.
If an error occurs while attempting to commit, for example if key-value coding validation fails, your implementation of this method should typically send the view in which editing is being performed a presentError:modalForWindow:delegate:didRecoverSelector:contextInfo: message, specifying the view's containing window.
You may find this method useful in some situations (typically if you are using Cocoa Bindings) when you want to ensure that pending changes are applied before a change in user interface state. For example, you may need to ensure that changes pending in a text field are applied before a window is closed. See also commitEditing which performs a similar function but which allows you to handle any errors directly, although it provides no information beyond simple success/failure.
Availability
- Available in OS X v10.4 and later.
Declared In
NSController.hdiscardEditing
Discards any pending changes by registered editors.
Discussion
The receiver invokes discardEditing on any current editors.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSController.hisEditing
Returns YES if there are any editors currently registered with the receiver, NO otherwise.
Availability
- Available in OS X v10.3 and later.
Declared In
NSController.hobjectDidBeginEditing:
Invoked to inform the receiver that editor has uncommitted changes that can affect the receiver.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSController.h© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-02)