Skip navigation.
 
mlNSPopUpButton displayed item - selected item
FROM : Henning Sauerland
DATE : Fri Apr 15 16:54:26 2005

I'm pretty new to Cocoa and have a problem with the NSPopUpButton.

The selected item is correctly saved in the preference-file, but the
NSPopUpButton doesn't display the selected item when I open the
preference panel, instead the first item is shown.

As said in the documentation "selectItemWithTitle" invokes
"synchronizeTitleAndSelectedItem" to ensure that the item being
displayed agrees with the selected item. If I understand it right, this
should exactly do what I'm looking for, but it won't work for me.


Here's a sketch of the code:

NSUserDefaults *prefs;
IBOutlet NSPopUpButton *profileSelect;

- (IBAction)savePrefs:(id)sender; {
   [prefs setObject:[profileSelect titleOfSelectedItem]
forKey:@"SelectedProfile"];
}

- (void)openPrefs {
   [profileSelect selectItemWithTitle:[prefs
objectForKey:@"SelectedProfile"]];
}



Henning

Related mailsAuthorDate
mlNSPopUpButton displayed item - selected item Henning Sauerland Apr 15, 16:54
mlRe: NSPopUpButton displayed item - selected item Henning Sauerland Apr 18, 09:42