Re: KVO of nested objects
Re: KVO of nested objects
- Subject: Re: KVO of nested objects
- From: Scott Stevenson <email@hidden>
- Date: Thu, 28 Oct 2004 20:14:52 -0700
On Oct 28, 2004, at 6:20 PM, Bruce Truax wrote:
Thanks for the suggestion. So what you are saying is that it is not
possible to observe the items of objects within objects.
It is possible, as long as they are reachable through key-value coding.
You *could* do it manually by observing each pikup object separately,
but this makes for rather long code that is tedious to maintain.
If I understand
correctly you suggesting that I create a dictionary within my ACSurface
object and that this dictionary contain dictionaries such as rdPikup
and
thPikup, each of which contain the isOn, surface, scale and offset
keys.
Yes.
I then tell my program to observe the isOn key and whenever the isOn
key in
any one of the xxPikup dictionaries is modified I will be sent a
notification.
Yes.
What I do not understand is how I will tell which of the
[xxPikup isOn] keys was modified.
The object that was modified and it the affected key is passed to you
in -observeValueForKeyPath:ofObject:change:context:
Also, how do I then bind these keys to my
UI elements? Do I create an object controller for each xxPikup key
contained in my ACSurface dictionary?
It really depends on how your UI is laid out. This is hard to
generalize on.
One object controller for each element seems like way too much. You
should be able to do everything you need to via the "key path" field in
the bindings panel.
But there's no way to explain the implementation details of this
without writing out a full tutorial right here in the email. You could
take a look at the tutorial I put together:
http://cocoadevcentral.com/articles/000080.php. Not exactly the same,
but should help you wrap your head around it.
Best Regards,
- Scott
--
http://treehouseideas.com/
http://theobroma.treehouseideas.com/ [blog]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden