Re: Binding NSMenuItem 1 to 1
Re: Binding NSMenuItem 1 to 1
- Subject: Re: Binding NSMenuItem 1 to 1
- From: Knut Lorenzen <email@hidden>
- Date: Wed, 22 Aug 2007 20:26:59 +0200
- Thread-topic: Binding NSMenuItem 1 to 1
Jeff Johnson schrieb dereinst (am 22.08.2007 17:24 Uhr) via
email@hidden:
<snip>
>>>> This seems convoluted and fragile -- what happens if the selected
>>>> object has no value for 'arbitraryKey'? What happens if your
>>>> model changes -- will you remember that that binding was
>>>> dependent on 'arbitraryKey'?
If there is no value for arbitraryKey, shouldn't Null Placeholder take care
of that?
And no, I probably wouldn't remember :) However, in my special case the
arbitraryKey chosen is guaranteed not to change.
>>>> It would be more robust and expressive to bind to, say, the array
>>>> controller' selectionIndexes (which is KVO compliant and provides
>>>> exactly the information you require) and determine whether the
>>>> count of the selected indexes is 1 using a value transformer...
>>>>
>>>> mmalc
That sounds like the most general solution and I'll take your advice!
<snip>
> Caveat: "selection.self" won't necessary work with objects that
> override "valueForKey:", such as NSDictionary.
I discovered that the hard way, since my NSArrayController holds
NSMutableDictionaries...
> Correction: "canRemove" doesn't return multiple value placeholders,
> so that won't work.
>
> I think that mmalc's solution should work in all cases, though it
> does require code outside of Interface Builder.
>
> -Jeff
Thanks again Jeff and mmalc!
Cheers,
Knut
_______________________________________________
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