[NSPopUpButton] "titleOfSelectedItem" ??

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

  1. macrumors regular

    Joined:
    May 6, 2011
    Location:
    Brisbane AUSTRALIA
    #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

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #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. thread starter macrumors regular

    Joined:
    May 6, 2011
    Location:
    Brisbane AUSTRALIA
    #3
    Thanks mFram,

    Will look at the IBOutlet tonight.
    Thanks heaps.

    Pete
     

Share This Page