• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails?


  • Subject: Re: Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails?
  • From: "Sean McBride" <email@hidden>
  • Date: Thu, 21 May 2009 12:43:04 -0400
  • Organization: Rogue Research Inc.

On 5/20/09 10:35 PM, Seth Willits said:

>I have an NSObjectController whose Content item is bounds to an
>object's "thing" path. I can then bind the values of controls in my
>nib to model key paths through that NSObjectController in the usual
>way. Those Value bindings can use "Conditionally Sets Enabled" and
>they work great.
>
>I have some controls where I'm not binding the Value though, and
>instead just need to bind Enabled alone, so that when there is no
>selection in the controller, those controls are disabled.
>
>The obvious way of doing that is to bind 'Enabled' to the
>NSObjectController's "selection" controller key, (no model key), and
>use the value transformer NSIsNotNil. Anytime the selection is not
>nil, the control is enabled... right? It's super simple, but it doesn't
>work, and I don't see why not.

My solution to all this was to create an NSValueTransformer subclass
that converts an NSArray/NSSet (anything that responds to count
actually) and converts to an NSNumber representing the number of items
in the collection.  Then I register 4 transformers named
RRCountIsZeroTransformer, RRCountIsNotZeroTransformer,
RRCountIsOneTransformer, and RRCountIsNotOneTransformer and use these in
my 'enabled' bindings.

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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

References: 
 >Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails? (From: Seth Willits <email@hidden>)

  • Prev by Date: Resizing Funky
  • Next by Date: Re: isKindOfClass returns null instead of YES or NO
  • Previous by thread: Re: Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails?
  • Next by thread: iPhone Photo Album and Camera Apps crashing
  • Index(es):
    • Date
    • Thread