PDA

View Full Version : [NSPopUpButton] "titleOfSelectedItem" ??




Fritzables
Jun 8, 2011, 09:25 PM
Hi to All,

As some of you are aware, I am in my very early stages of developping for Mac after leaving Windows to take up with Mac. I still have a lot to learn and enjoying the new skills.

My question is. If I have created an object of NSPopUpButton and called it myPopUp (in this example).

In it's simplessed form, would I return the string of the selected item like this:

NSString *returnedValue = [myPopUp titleOfSelectedItem];

Or have I missed the mark by a long shot ??

Pete



mfram
Jun 8, 2011, 09:49 PM
Well, probably the more standard way to do it is to create a Pop Up button by dragging it to your window in Interface Builder. Then create an outlet to the button in whatever controller you want.

Then yes, you should be able to call:

NSString *sel = [mybutton titleOfSelectedItem];

or maybe

NSInteger sel = [mybutton indexOfSelectedItem];

... which ever is more convenient. Assuming mybutton is declared as an outlet to the button.

Fritzables
Jun 8, 2011, 10:16 PM
Thanks mFram,

Will look at the IBOutlet tonight.
Thanks heaps.

Pete