NSPopUpButton displayed item - selected item
NSPopUpButton displayed item - selected item
- Subject: NSPopUpButton displayed item - selected item
- From: Henning Sauerland <email@hidden>
- Date: Fri, 15 Apr 2005 16:54:26 +0200
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden