Does NSUserDefaults save objects if the application becomes inactive?

江枫思渺然 提交于 2019-12-23 02:09:31

问题


For example:

NSUserDefaults *user = [NSUserDefaults standardUserDefaults];   
[user setObject:textField1.text forKey:@"receive_text1"];
[user setObject:textField2.text forKey:@"receive_text2"];
[user synchronize];

If I leave this app, just like from background to foreground, or relaunching the app

Could objects in NSUserDefaults still get the data that I set before?


回答1:


NSUserDefault is persistent. So the data will be saved until you remove them or delete the app from the device.



来源:https://stackoverflow.com/questions/4592550/does-nsuserdefaults-save-objects-if-the-application-becomes-inactive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!