Re: ArrayController vs Pop-up button vs Transformer -- three way tag team death match!
Re: ArrayController vs Pop-up button vs Transformer -- three way tag team death match!
- Subject: Re: ArrayController vs Pop-up button vs Transformer -- three way tag team death match!
- From: Quincey Morris <email@hidden>
- Date: Tue, 19 Apr 2011 01:19:48 -0700
On Apr 19, 2011, at 00:41, Ben Golding wrote:
> I am a bit stumped. I have an array controller which I have hooked up to a pop-up button and that works quite well. The members of the array are NSStrings but I would like to reformat them when they're displayed by the pop-up button. Seems fairly straightforward, I thought I'd just write a little transformer to do that.
>
> I plugged everything together and was surprised that that the transformer was raising an exception because it was being passed an NSObjectControllerProxy as its argument, not an NSString as I'd been expecting.
Can you list explicitly all the NSPopUpButton bindings you're using?
The bindings for popup buttons are very nasty. You have to figure out what/whether to bind 'content', 'contentObjects' and 'contentValues'. Only after you've got that right can you decide which of the 'selected...' bindings you want to use.
'content', 'contentObjects' and 'contentValues' correspond to controller proxies, strings and represented objects, but I couldn't tell you off-hand which corresponds to what. It's anybody's guess whether the documentation (http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSPopUpButton.html) is actually correct -- several of the pages in that document are wrong and/or incomplete -- and it's a puzzle sometimes to understand what the documentation even means.
TBH, I've generally found it easier *not* to use bindings for NSPopUpButton content, but provide it the traditional way ('-[NSPopUpButton insertItem...]'), and just use a binding for 'selectedIndex'. But maybe I'm just a coward.
_______________________________________________
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