Re: How to use bindings on a specific array element
Re: How to use bindings on a specific array element
- Subject: Re: How to use bindings on a specific array element
- From: George Orthwein <email@hidden>
- Date: Wed, 6 Jun 2007 12:13:29 -0400
Basically, you can't bind to individual array items through the
controller... though I understand the expectation as it was something
that took a while to sink in for me as well.
The closest you can get is the selected object or something like the
max value, min value, etc using set and array operators.
http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueCoding/Concepts/ArrayOperators.html
What you can do, is use a dictionary so you can refer to each element
with a key name. So, set up an NSObjectController with class
NSMutableDictionary and add each individual key (e.g.
"data1","data2","data3"). You can then bind to those keys.
Of course, if you're dealing with 50 (or even 10) of something, then
you might very well want to handle the creation and binding
programmatically anyway.
George
On Jun 5, 2007, at 5:18 PM, Arthur C. wrote:
This must be a basic bindings question, but I haven't solved it in
a convenient way so far.
When I have say 10 custom views in my window, I get 10 items in my
NIB file. Each of the views has to be bound to one instance of some
class which delivers the data/image to be shown. What I have done
so far is instantiate the class 10 times in the NIB, and then
create the bindings. But this makes my interface file quite large
and messy (what if I decide to have 50 of them?)... I wonder if
it's possible to create an array programmatically, something like
[myArray addObject: [[myClass alloc] init]];
and have each of the custom views bound to array element 0, 1,
2, ... respectively. This cleans up the NIB file and makes it a lot
easier to access all the myClass instances.
But maybe there is another way to accomplish something like this?
Well, thanks for your help,
Arthur C.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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