• 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: Conditionally enable a button based on NSArrayController's selectedObjects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conditionally enable a button based on NSArrayController's selectedObjects?


  • Subject: Re: Conditionally enable a button based on NSArrayController's selectedObjects?
  • From: Ondra Cada <email@hidden>
  • Date: Fri, 28 Apr 2006 21:44:15 +0200

John,

On 28.4.2006, at 21:31, John Fox wrote:

(Is there a way to bind to the count of selecteObjects without having to write a method in my controller? I tried selectedObjects.count, but that didn't work)

selectedObjects.@count should work (read the KVC manual for more of these tricks).


- (BOOL)hasSelectedObjects {
    return ([self selectedObjects] && [[self selectedObjects] count]);
}

The problem is that as selectedObjects changes in my array controller, the above method is not called. Bummer. I could override setSelectedObjects: I'm sure, but then why use bindings at all?

It *should* be solvable by a simple +initialize with setKeys:triggerChangeNotificationsForDependentKey: (read on KVO :))


For some reason which I don't get (halo? MMalc? Can you perhaps elucidate? Or another guru?) though it does not. See

http://www.cocoabuilder.com/archive/message/cocoa/2006/3/13/158573

for details and (ugly, but useable) work-around.
---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Conditionally enable a button based on NSArrayController's selectedObjects? (From: John Fox <email@hidden>)

  • Prev by Date: Re: Getting a NSView pointer from a nib
  • Next by Date: Re:(no subject) getting an NSUndoManager in an OCUnit test case
  • Previous by thread: Conditionally enable a button based on NSArrayController's selectedObjects?
  • Next by thread: Re: Conditionally enable a button based on NSArrayController's selectedObjects?
  • Index(es):
    • Date
    • Thread