• 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: Seemingly Simple Bindings Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Seemingly Simple Bindings Question


  • Subject: Re: Seemingly Simple Bindings Question
  • From: Graham Cox <email@hidden>
  • Date: Mon, 1 Sep 2008 09:58:59 +1000


On 1 Sep 2008, at 9:38 am, Jamie Phelps wrote:

I have an NSPopUpButton with five menu items: WTD, MTD, QTD, YTD, and Specific Dates. What I want to do is show and hide two labels and textfields for Start Date and End Date depending on if the Specific Dates option is selected.

My first attempt was to do

@property (readonly) BOOL specifyingDateRange;

-(BOOL)specifyingDateRange{
   if([dateRangePopUp indexOfSelectedItem] == 4){
       return YES;
   }
   return NO;
}

but this is not working correctly.

Can anyone explain what the correct implementation is and possibly what mistake I made in assessing the problem?


You probably don't want to tie the functionality to a specific item index - it makes it hard to easily change the UI without breaking (or needing to revise) the code. Instead, you could use a tag value to represent the item's function, or possibly its representedObject.

Not being familiar with bindings, I can't be sure how this relates to that, but more conventionally you'd set an action and target for your pop-up menu and the action's signature would look like:

- (IBAction)	respondToDateRangePopUp:(id) sender
{
    if([sender tag] == kTheTagImLookingFor)
	[self doSomething];
}


hth,

Graham
_______________________________________________

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: 
 >Seemingly Simple Bindings Question (From: Jamie Phelps <email@hidden>)

  • Prev by Date: Re: App names
  • Next by Date: Re: Trouble with Scripting Bridge
  • Previous by thread: Seemingly Simple Bindings Question
  • Next by thread: Re: Seemingly Simple Bindings Question
  • Index(es):
    • Date
    • Thread