cocoa touch - settings bundle - default value behaviour? -


i have created settings bundle single preference value, text field default value.

when application launches , retrieve value null. have manually code value use before user has provided value?

also if user preferences screen , enters text field leave without making changes value not set ... user has change value saved, correct?

no, don't that.

there's function this:

id userdefaults = [nsuserdefaults standarduserdefaults]; [userdefaults registerdefaults: defaultsettings]; 

you can build parameter iterating sub keys of preferencespecifiers in settings plist file.

something this:

- (nsdictionary *)readdefaultsettingsfromplist: (nsstring *)inpath; {     id mutable = [nsmutabledictionary dictionary];     id settings = [nsdictionary dictionarywithcontentsoffile: inpath];     id specifiers = [settings objectforkey: @"preferencespecifiers"];     (id prefitem in specifiers) {         id key = [prefitem objectforkey: @"key"];         id value = [prefitem objectforkey: @"defaultvalue"];         if ( key && value ) {             [mutable setobject: value                         forkey: key];         }     }     return [nsdictionary dictionarywithdictionary: mutable]; } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -