load/save settings in iOS

后端 未结 2 726
忘了有多久
忘了有多久 2021-01-30 11:23

I have the following two procedures defined in my AppDelegate. saveSettings and loadSettings. I am calling my loadSettings procedure in the AppDidFinishLaunching method, and I a

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 12:00

    to make it sample:

    //Writing
    [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"anInt"];
    [[NSUserDefaults standardUserDefaults] setDouble:1.2 forKey:@"aDouble"];
    [[NSUserDefaults standardUserDefaults] setString:@"aString" forKey:@"aString"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    
    //Reading:
    
    int i = [[NSUserDefaults standardUserDefaults] integerForKey:@"anInt"]
    

提交回复
热议问题