我使用“plist”文件来存储我的设置。我找到的唯一答案是保存此目录中的文件:
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
但我不知道该怎么做。
最佳答案
阅读文档:NSUserDefaults
The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an application to customize its behavior to match a user’s preferences. For example, you can allow users to determine what units of measurement your application displays or how often documents are automatically saved. Applications record such preferences by assigning values to a set of parameters in a user’s defaults database. The parameters are referred to as defaults since they’re commonly used to determine an application’s default state at startup or the way it acts by default.
因此您可以在 NSUserDefaults 中保存和读取您的设置。
//write to standard defaults
[[NSUserDefaults standardUserDefaults] setObject:yourObject forKey:@"kYourKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
//read from standard defaults
yourObject = [[NSUserDefaults standardUserDefaults] objectForKey:@"kYourKey"];
下次尝试更具体地说明您想做什么。
关于iphone - iOS。应用程序更新后保护设置不被重置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8179292/