How to save the state of an NSPopUpButton? - Cocoa -
How to save the state of an NSPopUpButton? - Cocoa -
i have been searching everywhere , not been able find , bugging me. can't figure out how save current state of nspopupbutton, if user changes it, app load state next time run app. have tried nsuserdefaults , been adding new item pop button has weird name.
it sounds you've failed set initial value user default.
for example, if bind nspopupbutton
using "selected value" binding default "popupselection" must insure nsuserdefaults
always returns 1 of nspopupbutton
's entries "popupselection".
you accomplish including plist in project, "defaults.plist", contains default value wish "popupselection" (and default values wish other preferences), @ application startup load plist bundle:
nsstring *defaultspath = [[nsbundle mainbundle] pathforresource:@"defaults" oftype:@"plist"]; nsdictionary *defaultsdict = [nsdictionary dictionarywithcontentsoffile:defaultspath]];
and register these defaults nsuserdefaults
:
[[nsuserdefaults standarduserdefaults] registerdefaults:defaultsdict];
now popup button start right value, , binding maintain value in nsuserdefaults
right when user changes selection.
cocoa save nspopupbutton
Comments
Post a Comment