1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

[NSPopUpButton] "titleOfSelectedItem" ??

Discussion in 'Mac Programming' started by Fritzables, Jun 8, 2011.

  1. macrumors regular

    #1
    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:

    Code:
    NSString *returnedValue = [myPopUp titleOfSelectedItem];
    Or have I missed the mark by a long shot ??

    Pete
     
  2. macrumors 6502a

    #2
    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:

    Code:
    NSString *sel = [mybutton titleOfSelectedItem];
    or maybe

    Code:
    NSInteger sel = [mybutton indexOfSelectedItem];
    ... which ever is more convenient. Assuming mybutton is declared as an outlet to the button.
     
  3. macrumors regular

    #3
    Thanks mFram,

    Will look at the IBOutlet tonight.
    Thanks heaps.

    Pete
     

Share This Page