Re: Binding values from an array in IB
Re: Binding values from an array in IB
- Subject: Re: Binding values from an array in IB
- From: Dustin Voss <email@hidden>
- Date: Sat, 29 May 2004 15:08:58 -0700
On 28 May, 2004, at 6:46 PM, Christoffer Lerno wrote:
Hi,
I have an NSObjectController based on a NSMutableDictionary. Anyway,
binding values to the interface is straightforward for single values
of course. However, one of my values is an NSArray and I want to bind
each element to a certain NSTextView.
I get the array like this:
NSArray theArray=[objectControllerDictionary objectForKey:@"goods"];
And I want to extract it's values:
NSNumber theOreAmount=[[objectControllerDictionary
objectForKey:@"goods"] objectAtIndex:2];
and bind theOreAmount to the value of a NSTextView
Is it possible to create some path,
selection.goods.somethingtakingindex2 to get to this value or do I
have to go by-way of value transformers?
It sounds like your array should really be a dictionary. You might want
to consider making that change.
Another option would be to make the text fields into an NSMatrix, and
bind NSMatrix's "content" to "selection.goods". Then there would be a
one-to-one correspondence between the fields and the elements of the
array.
A third option is to make a subclass of NSArrayController's
valueForKeyPath: method, and add in support for a key-path like
"selection.goods.@2".
_______________________________________________
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.