Re: NSEditor, NSEditorRegistration Protocols
Re: NSEditor, NSEditorRegistration Protocols
- Subject: Re: NSEditor, NSEditorRegistration Protocols
- From: Allan Odgaard <email@hidden>
- Date: Wed, 3 Mar 2004 10:54:42 +0100
On 3. Mar 2004, at 2:49, Alan Donsky wrote:
Anybody know about these informal protocols? I am trying to
implement an NSView subclass that uses bindings and i think these
protocols are involved in telling the controller that the view has
changed so it can update the model.
I think it has already been stated, but these are not required. Simply
expose your key and make all changes to that key either through
set<Key>: or setValue:forKey:, these methods will send a
will/didChangeValueForKey:, which the controller should observe -- and
this is how it knows about changes made to your view.
The editor protocols are for stuff like text fields where each change
in the view does not update the model -- so the view will send an
objectDidBeginEditing: to the controller when editing starts (for text
fields that is when it becomes first responder), and while editing is
happening, the controller can send commitEditing or discardEditing
(either on request or if the application quits, needs to save the
document etc.). When the view completes the edit, it'll send
objectDidEndEditing: -- at least this is my interpretation of the docs.
It seems like a sloppy implementation, and the online documentation
sucks. How is the view even supposed to send the message to the
controller without having an outlet to that controller?
Yes, that is weird -- though there is a private NSObject method:
_bind:toController:withKeyPath:valueTransformerName:options:
existingNibConnectors:connectorsToRemove:connectorsToAdd:
Probably this plays a role in having the view know about its
controller. Perhaps this explains why IB will only bind to controllers.
I wonder if this controller/view "editor" relationship will work if
manually created!?!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.