Re: NSView subclass + manual binding
Re: NSView subclass + manual binding
- Subject: Re: NSView subclass + manual binding
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 10 Feb 2004 01:03:43 -0800
On Feb 9, 2004, at 12:49 AM, Raphael Sebbe wrote:
Using manual binding, I found it is possible to directly bind the view
to the document, using smth like this:
[_targetView bind:@"time" toObject:self withKeyPath:@"editingTime"
options:nil];
[self bind:@"editingTime" toObject:_targetView withKeyPath:@"time"
options:nil];
What are pros/cons of using direct binding, as opposed to using a
controller in between ?
Am I forced to have bi-directional binding in the case of direct
binding (it seems to) ?
Loosely speaking, the NSController does more for you.
More specifically, it serves as a proxy for the object you to which you
wish to bind. This makes setting up a user interface much more
flexible. If part of the underlying model changes, you should be able
to change a single keypath in the NSController instead of re-writing a
potentially large number of lines of code used to set up bindings
programatically (recall that much of the idea here was to reduce the
amount of code you have to write...) You are very much encouraged to
use NSController subclasses to serve as proxies for your model
objects...
If you simply want to ensure that two values are kept in sync without a
controller, you are encouraged to use key-value observing.
mmalc
(With thanks to Andreas and Scott.)
_______________________________________________
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.