applicationWillTerminate and applicationDidEnterBackground don't get called [duplicate]

StackOverflow https://stackoverflow.com/questions/8111064

  •  27-02-2021
  •  | 
  •  

سؤال

I'm trying to implement saving user's data in my application. I've created special method named saveUserInfo which is called when user logs out (and for this event everything works great just as i want it to). Also i want user's data to be saved when the app's execution is over, so i've put my saveUserInfo method into applicationWillTerminate and applicationDidEnterBackground methods. And that works partly. When i press HOME button - applicationDidEnterBackground is called and saveUserInfo works as it supposed to. But when i press "Stop the running scheme or application" button in my Xcode 4 neither applicationWillTerminate nor applicationDidEnterBackground are called so user's info is not saved. What am i doing wrong? Or maybe i'm doing everything correctly and applicationWillTerminate and applicationDidEnterBackground are not supposed to get called by pressing "Stop the running scheme or application" button in Xcode? I just can't find satisfactory answer

هل كانت مفيدة؟

المحلول

The stop button in Xcode kills you app there and then. It is normal that it does not go through the usual applicationWillTerminate callback.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top