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

Conditionally enable a button based on NSArrayController's selectedObjects?


  • Subject: Conditionally enable a button based on NSArrayController's selectedObjects?
  • From: John Fox <email@hidden>
  • Date: Fri, 28 Apr 2006 12:31:03 -0700

Hello:

I'm trying to enable/disable an action button based on whether or not selectedObjects has at least one object. I thought this should be simple, but maybe I'm just dull and stupid. In IB, I connected the "enabled" to a method I created in my controller which looks like this:

(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)

- (BOOL)hasSelectedObjects
// Used to enable/disable an action button
{
    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?

I apologize if this is obvious. I really did RTFM and try Google.

Best,

John
_______________________________________________
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


  • Follow-Ups:
    • Re: Conditionally enable a button based on NSArrayController's selectedObjects?
      • From: Ondra Cada <email@hidden>
    • Re: Conditionally enable a button based on NSArrayController's selectedObjects?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: comboboxcell datasource problem
  • Next by Date: Re: Getting a NSView pointer from a nib
  • Previous by thread: Re: Binding Text Field to Show Time Interval?
  • Next by thread: Re: Conditionally enable a button based on NSArrayController's selectedObjects?
  • Index(es):
    • Date
    • Thread