Re: Cancelling state restoration on iOS
Re: Cancelling state restoration on iOS
- Subject: Re: Cancelling state restoration on iOS
- From: Sixten Otto <email@hidden>
- Date: Tue, 25 Jul 2017 20:28:19 -0700
You can set a custom restorationClass on a per view controller basis,
passing the process of instantiating the controller during restoration
through your own code that knows how to check whether the document is still
there. (We do something similar in our app in some places to make sure that
our Core Data store is present, and contains the objects the stored state
had been displaying.)
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621472-restorationclass
(It is true, though, that this cannot abort the *entire* restoration
process. Just prune sub-trees of the view controller graph.)
On Tue, Jul 25, 2017 at 12:50 PM, Steve Mills <email@hidden> wrote:
> There doesn't appear to be any way to cancel state restoration other than
> from the app delegate method application:shouldRestoreApplicationState:.
> So if it's trying to restore a view controller for a document that is no
> longer available on the device, I want to cancel the whole restoration. The
> only object that knows which document was previously open is the view
> controller that displays the document. But the only methods offered for
> decoding a VC's state is decodeRestorationStateWithCoder:, which doesn't
> return anything like a BOOL to say if it could be restored or not.
>
> Any ideas?
>
> --
> Steve Mills
> Drummer, Mac geek
>
> _______________________________________________
>
> 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