NSUserDefaults Settings Bundle Plist

后端 未结 2 1682
星月不相逢
星月不相逢 2021-01-25 00:15

I have an app that checks for a file upon load from the appDelegate\'s appDidFinishLoading method using a url value that I supposedly store in the NSUserDefaults Settings Root P

相关标签:
2条回答
  • 2021-01-25 00:25

    Turns out I was missing this line:

    nsUserDefURL = [[NSUserDefaults standardUserDefaults] stringForKey:kFirstNameKey];  
    

    But this only reads the default value each launch. It won't save the user modified value in the app settings. Why is that value not being saved?

    0 讨论(0)
  • 2021-01-25 00:26

    You'll need to explicitly save it. For example, if strFirstName is the value that the user modified, then you would save it to the app settings by

     NSUserDefaults* ud = [NSUserDefaults standardUserDefaults];
     [ud setObject:strFirstName forKey:kFirstNameKey];
     [ud sychronize];
    
    0 讨论(0)
提交回复
热议问题