applicationWillTerminate works as long as I don't switch off the iPhone

前端 未结 2 353
执笔经年
执笔经年 2021-01-26 06:44

to save some variables of my apps I use:

-(void)applicationWillTerminate:(UIApplication *)application {

NSUserDefaults *prefs = [NSUserDefaults standardU         


        
2条回答
  •  猫巷女王i
    2021-01-26 07:03

    According to Apple's documentation

    "NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value."

    If you want to make sure things are saved you should call "synchronize" on your prefs.

提交回复
热议问题