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.
David Phillip Oster - 26 Apr 2008 04:09 GMT
In article
<1049c344-9701-4468-b855-ec35f87871da@a23g2000hsc.googlegroups.com>,
> 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.
Are you setting your list of currencies in I.B.?
jim - 26 Apr 2008 09:12 GMT
> 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:@"Dollars to UK Pounds"];
[currencyButton addItemWithTitle:@"Dollars to Euros"];
[currencyButton addItemWithTitle:@"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

Signature
"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