iphone - Saving Core Data when the user exits the application? -
I am trying to save the core data while pressing the home button on the Home button. I will do it from . I did this in the end: Check out. In fact, this part may interest you about the By adjusting your user interface before this method Any other related work should be done, but other tasks (such as savings status) can be transferred to the concurrent dispatch queue or secondary thread as necessary. Because it is likely that you start any background work in the background, which starts in the App Deedenter background: not to run until after leaving that method, before you start those tasks, additional background performance time Should request. In other words, first start the callBackagerTap DetailsExperienceHandler: and then run the task on a dispatch queue or secondary thread. -applicationDidEnterBackground Wanted: but it is not being called. This is probably because you can not save core data here or just because there is not enough time to complete the operation. Although it works with
-applicationWillResignActive: I'm just curious who is the best representative method to do this and why
-applicationDidEnterBackground: is not working (as You can see from the output that both the methods are being called, if I remove it from
-applicationWillResignActive: does not occur, so this is not the case when blocking someone else )
// Call Save - (empty) application Iseshgyanatmk action: (Uaiapiplikeshn *) application {[self-model] Shejenkoretata: Save @ "application Willilrasaktivakt"]; NSLog (@ "APPDEL:% s", __PRETTY_FUNCTION__); } / / No left - (zero) applicationDidderbackground: (UIApplication *) application {[[self model] saveCoreData: @ "Save from: applicationDidEnterBackground"]; NSLog (@ "APPDEL:% s", __PRETTY_FUNCTION__); }
// console output 2013-03-21 cvb [6724: 907] epodele: [[adelelegate application will will be active]: 2013-03- 21 cvb [6724: 907] apdl: [ Adelaget App Didender Background:] 2013-03-21 CVB [6724: 907] 2013-03-21 CVB [6724: 907] Save: Save: Application: RisineActive 2013-03-21 CVB [6724: 907] Save: Successful Save ...
Edit:
- (empty) applicationDidendarbackground: ( UIApplication *) Un Application {__bloc UIBackgroundTaskIdentifier bgTask = [Application Started BackgroundTaskWithExpirationHandler: ^ {[Application Endbacker Task: BGTs]; BgTask = UIBackgroundTaskInvalid; }]; [[Self model] saveCoreData: @ "[open background]"]; }
applicationDidEnterBackground:
Comments
Post a Comment