Reputation: 4277
I noticed when Xcode generates a Template with Core Data checked, this line:
[self saveContext];
which saves all the objects to the database, is inserted inside "applicationWillTerminate:".
Shouldn't this method called inside "applicationDidEnterBackground:" instead, especially if we have a lot of data to save? For example, if there is 0.5 seconds needed to save everything, but the system kills the app for some reason after 0.4 seconds, is it possible that not all the data will be saved? Or is it the ACID properties guarantee that data would be saved no mater what happens?
Thanks in advance!
Upvotes: 0
Views: 27
Reputation: 221
as you said, saving data when going to background is dangerous as it could take too much time especially if you do graphic stuff at the same time. If your app is killed by system when in bg then the "will terminate" method is called and thus data are saved. If not then maybe you could do a save at next launch, but generally you should handle save after each important operation involving deletion/insertion of data.
Upvotes: 1