can not set the bool value of app setting

Posted by user262325 on Stack Overflow See other posts from Stack Overflow or by user262325
Published on 2010-04-20T03:04:56Z Indexed on 2010/04/20 3:13 UTC
Read the original article Hit count: 396

Filed under:

Hello everyone I use the codes below to read and write a bool value from my application:

-(void)SaveAppSetting;
{
    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];

    bool b=true;
    [defaults setBool:b forKey:@"AnyKey"];
    [defaults synchronize];
}
-(void)LoadAppSetting;
{
    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
    bool b=[defaults boolForKey: @"AnyKey"] ;


}

I found that "LoadAppSetting" worked well, it could get the correct value of item with key "AnyKey". The function "SaveAppSetting" looked like no function, it reported no error, but it can not change value of the item with key "AnyKey".

"AnyKey" setting in Setting bundle is

item               Dictionary
Type               String       PSToggleSwitchSpecifier
Title              String       AnyKey's Title
Key                String       AnyKey
DefaultValue       Boolean      Checked

Is there any person met the same problem? Thanks interdev

© Stack Overflow or respective owner

Related posts about iphone