load/save settings in iOS

后端 未结 2 727
忘了有多久
忘了有多久 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 11:43

    Doh.

    In saveSettings, I was missing my [prefs synchronize];

    0 讨论(0)
  • 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"]
    
    0 讨论(0)
提交回复
热议问题