Re: Binding to an array.name, how?
Re: Binding to an array.name, how?
- Subject: Re: Binding to an array.name, how?
- From: Bob Ippolito <email@hidden>
- Date: Mon, 16 May 2005 01:41:06 -0400
On May 16, 2005, at 1:18 AM, Glen Low wrote:
I've created my own subclass of NSController and called
exposeBinding for the various bindings available on it. Each
binding corresponds exactly with a KVC-compliant pair of methods
e.g. array and setArray.
Now I can easily bind arrays of simple values to the binding.
However, supposing I have an array of dictionaries, each dictionary
with a key of "name", I find I cannot bind to array.name... it
fails at runtime with a
[<NSCFArray 0x3b85e0> addObserver:forKeyPath:options:context:] is
not supported. Key path: name
On the other hand, this is precisely the technique used for
NSPopUpButton's binding contentValues: provided I bind content
first to the array, I can bind contentValues to array.name with no
problems. If I don't bind the content first, then it fails with the
above error.
So the question is: How does NSPopUpButton allow or implement
binding its contentValues to an array.name, where name is a field
of the dictionary which is an element of array? (Hope that's clear...)
This is just a guess, as I haven't tried it, but perhaps KVO only
works for arrays if you implement indexed accessors (countOfArray,
objectInArrayAtIndex:, insertObject:inArrayAtIndex:,
removeObjectFromArrayAtIndex:).
-bob
_______________________________________________
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