Re: More bindings confusion
Re: More bindings confusion
- Subject: Re: More bindings confusion
- From: Allan Odgaard <email@hidden>
- Date: Sun, 18 Jul 2004 10:30:21 +0200
On 16. Jul 2004, at 8:59, ScottAnguish wrote:
So if I bind a view's "enabled" binding to Shared Application using
the model key path "delegate.kvcCompliantMethod", and implement
kvcCompliantMethod in the NSApplication delegate, it will work, but I
lose... what?
As I said, you shouldn't, you should use an object controller as an
intermediate.
an object controller knows when the document needs to get/abandon
changes, and is informed when the UI items change focus, which can
cause changes to be committed or abandoned.
How does it know when changes needs to be committed or discarded? will
it register itself as an observer of NSWindowWillCloseNotification,
NSApplicationWillTerminateNotification, and further get (undocumented?)
messages from the NSDocument etc. before it is about to save?
Or is it my responsibility to send commit/discardEditing to the
intermediate NSObjectController instance at the proper time(s)? cause
then I'd agree with the OP that it is really just a proxy for the
active text field, at the cost of one more object in my Nib and one
more outlet in my File's Owner (although that wasn't his exact words ;)
).
always use an object controller. always always always.
Of cause if one needs the placeholder stuff or similar, I can see the
use for the intermediate object -- but if e.g. I need to bring up a
requester with a checkbox or similar, I really fail to see why I
shouldn't just bind the checkbox directly to [File's
Owner].someBooleanInstanceVariable (even making the horrible sin of not
providing set and get methods for it ;) ) -- with text fields this
won't work, but setting the "Continuously Updates Value" should
eliminate the need for NSEditorRegistration (although this informal
protocol could be handled by File's Owner, adding 6 lines of code --
wether this is to prefer over the outlet and extra IB object(s) is
probably a matter of taste).
Regards Allan
_______________________________________________
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.