Does NSUserDefaults save objects if the applicatio

2019-06-07 00:20发布

问题:

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.