• 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: Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey?


  • Subject: Re: Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey?
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 2 Apr 2010 22:33:59 -0700

On Fri, Apr 2, 2010 at 8:25 PM, Jerry Krinock <email@hidden> wrote:
> I solved the problem by eliminating all this code and binding my button's 'enabled' binding instead to the array controller's 'selection' and, to my surprise, it worked.  My surprise is because, according to superclass NSObjectController documentation, 'selection' returns NSNoSelectionMarker when there is no selection, not nil which is what my NSIsNotNil value transformer would expect.

While this works (I imagine that -[NSButtonCell setObjectValue:]
treats NSNoSelectionMarker specially) I would think that the "right"
thing to do would be to subclass NSArrayController and write a
-canPerformFoo method. But you would need to self-observe the
selection property, which is perilous because
-removeObserver:forKeyPath: doesn't take a context argument (another
bug every Cocoa developer should file a duplicate of). So you could
use MAKVONotificationCenter (or OFBinding, our analogue) to
self-observe. Perhaps it would be easier to instead put the
-canPerformFoo method on your window controller.

--Kyle Sluder
_______________________________________________

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

  • Follow-Ups:
    • Re: Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey?
      • From: Jerry Krinock <email@hidden>
References: 
 >Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey?
  • Next by Date: NSXMLElement and namespaces
  • Previous by thread: Re: Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey?
  • Next by thread: Re: Why doesn't -[NSArrayController selection] et al fire keyPathsForValuesAffectingKey?
  • Index(es):
    • Date
    • Thread