Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / April 2008



Tip: Looking for answers? Try searching our database.

NSPopUpButton

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
joe.garifo@gmail.com - 25 Apr 2008 21:51 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.
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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.