<joe.garifo@[EMAIL PROTECTED]
> wrote:
> I'm trying to teach myself objective C and was working on the tutorial
> from Apple on Cocoa. I tried to add a NSPopUpButton using IB to list
> different currencies to choose from. My first issue is that when it
> first starts up it lists the default 3 items, but once you hit the
> button it lists mine. My second is that once it gets to that, it only
> uses the rate of the first item on the list. Any help would be lovely.
As a suggestion:
In Interface Builder doubleclick your popupbutton and delete all three
entries (the items marked 'Item 1', 'Item 2' and 'Item 3'). Save.
In your object have a section like this:
-(void)awakeFromNib
{
[currencyButton addItemWithTitle:@[EMAIL PROTECTED]
"Dollars to UK Pounds"];
[currencyButton addItemWithTitle:@[EMAIL PROTECTED]
"Dollars to Euros"];
[currencyButton addItemWithTitle:@[EMAIL PROTECTED]
"Dollars to Credits"];
}
where 'currencyButton' is an IBOutlet pointing at your popupButton.
Then, assuming your popupButton is also pointing at an IBAction you can
read the selected option like this:
-(IBAction)buttonPressed:(id)sender
{
int convertOption = [sender indexOfSelectedItem];
....
}
convertOption will be 0 for the first item, 1 for the second etc.
Jim
--
"Well, well. We've come a long way from the Prime Minister's
exploding cake." - Adam West, Batman.
Find me at http://www.UrsaMinorBeta.co.uk


|