Re: CoreData UIManagedDocument saving/closing questions
Re: CoreData UIManagedDocument saving/closing questions
- Subject: Re: CoreData UIManagedDocument saving/closing questions
- From: email@hidden
- Date: Thu, 30 Aug 2012 19:34:02 -0400
I asked the question in quote email two days ago with no response so let me try a related, but perhaps more concise/simpler question:
Is it even necessary to call -saveToURL:forSaveOperation:completionHandler in a UIManagedDocument subclass or will its autosaving mechanism take care of that at all times, including requesting extra time with a [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler: block when necessary.
In other words, can I remove all calls to -saveToURL:forSaveOperation:completionHandler other than the one used to create a new file? I am not currently using iCloud.
The symptom I'm seeing is about 1% of the people who have purchased my app are losing the data files (they seem to have zero size). I can't reproduce it and I've been using the app for 8 months while developing it without ever seeing this. I don't know if it's a save issue or if perhaps something such as a required entity attribute not getting set that is leading to the zero length file.
I would be extremely grateful for any suggestions on how to track this down as I've temporarily pulled the app from the store until I can figure this out.
Thanks,
Dave
On Aug 28, 2012, at 10:17 PM, email@hidden wrote:
>
> This is on iOS 5 and higher.
>
> I have an iOS app that can open separate data files (one open at a time) using a UIManagedDocument subclass.
>
> When I do a -saveToURL:forSaveOperation:completionHandler
>
> do I need to that inside a:
>
> [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:
>
> block in case the application enters the background and will be terminated before the save operation completes? Or does UIManagedDocument take care of that for me?
>
> Also, my app delegate's
>
> - (void)applicationDidEnterBackground:(UIApplication *)application
>
> do I need to call:
>
> - (void)closeWithCompletionHandler:(void (^)(BOOL success))completionHandler
>
>
> and then reopen it in:
>
> - (void)applicationWillEnterForeground:(UIApplication *)application
>
>
> Or can I just call:
>
> -saveToURL:forSaveOperation:completionHandler
>
> in
>
> - (void)applicationDidEnterBackground:(UIApplication *)application
>
> without worrying about closing the file if the app is later terminated?
>
> Thanks,
> Dave
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden