What is the correct way to save NSUserDefaults when my app is terminated on iOS

后端 未结 4 994
不知归路
不知归路 2021-02-10 03:16

I need to save my NSUserDefault when my app is completely quit in iOS. not didenterbackground and foreground. Only when user kill my app w

4条回答
  •  时光取名叫无心
    2021-02-10 03:44

    When an app is ended from the multitasking bar, is is simply killed. There is no delegate method called. willTerminate is called for apps that do not support multitasking when the home button is hit.

    Apps by default support multitasking, so you should be doing everything you need to do in didEnterBackground. After that, you can't guarantee that any of your code will be called again.

提交回复
热议问题