Re: bindings and sub array modification notification.
Re: bindings and sub array modification notification.
- Subject: Re: bindings and sub array modification notification.
- From: Sandro Noel <email@hidden>
- Date: Sun, 18 Jan 2009 23:54:34 -0500
Quincey,
Thank you for taking the time to explain. It is very appreciated.
With this explanation in mind my approach to save my files when the
array changes is not a good way to go.
I'll change the code.
Thank you very much. :)
Who owns what/who is a little confusing for me at this stage in my
learning of the Cocoa/Objective-C structure
Memory management, bindings, delegates, controllers, Key-Value, some
Carbon, I'm mixing in all the elements and
all the new terms, Sorry if it causes confusion and makes helping more
tedious. I'll get there :)
Sandro Noel.
On 18-Jan-09, at 11:37 PM, Quincey Morris wrote:
On Jan 18, 2009, at 17:02, Sandro Noel wrote:
How could I possibly observe the changes in the information array
or each host element?
or if no possible, the currently selected host...
I currently have an observer on the hosts array, and that works
when the array is changed(added/deleted),
but i would need to get notification when the content of a "host"
is also changed.
is that possible ?
There's no magic involved. Your observer has to say it wants to
observe, with object/key-path granularity:
[host addObserver: self forKeyPath: @"firstProperty" ...];
[host addObserver: self forKeyPath: @"secondProperty" ...];
...
Repeat for each host (as you add it to the array of hosts, for
example).
Of course, in many cases you don't need or want to set up systematic
observations of all properties of all objects like this*. In many
cases, observations result from the use of bindings. When you use a
binding in IB (from, say, a NSTableColumn), adding itself as an
observer is one of the things that the observing UI element does for
itself, and supporting bindings by watching for the comings and
goings of objects in array properties is in fact the fundamental
purpose of the NSArrayController class.
BTW, you don't "have an observer on the hosts array", you have an
observer on the "hosts" property of the object that owns the hosts
array. If you religiously train yourself to think and speak in terms
of (owning) object *having* a property instead of (value) object
*being* a property, you'll save yourself a lot of grief.
*One good reason for systematically observing all properties of all
objects in your data model is automatic invocation-based undo.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden