Cryptic warning without any google results [In Simulator]
Asked Answered
M

3

13

I get this warning in my iOS project: (iOS7, XCode 5 GM)

Warning: Unable to create restoration in progress marker file

I am working on a viewcontroller that turns all black when I get this warning on startup. Deleting the app and restarting XCode sometimes seems to help. I am returning NO on both

-(BOOL)application:(UIApplication *)application shouldRestoreApplicationState:
-(BOOL)application:(UIApplication *)application shouldSaveApplicationState:

Update1: I tested on iPhone4s. Same result. Warning and black screen on my view controller.

Update2: Answered my own question for the black screen. The warning just disappeared in latest iOS 7.0.x versions.

Metcalfe answered 21/9, 2013 at 11:42 Comment(6)
I get this warning as well, not sure what the cause isPoppyhead
How are your view controllers created? Are they in a storyboard, or nibs, or created within your app delegate, or ...Elyot
I am using storyboard with navigation view controller as its base. I am trying to integrate state restoration. This message shows up even on fresh starts of the app (deleted and deployed again).Metcalfe
I notice something else yesterday. ViewController through Storyboards use initWithCoder to init themselves. I made a coding mistake on my BaseViewController (I use it as a base for all my viewcontrolelrs). I called the normal [super init] method, not [super initWithCoder:aDecoder] as I should have. This mistake made my initial screen simply black without any error. Unfortunately this does not answer my question.Metcalfe
@EvgeniPetrov - Please see my updated answer. I think the problem is resulting from a missing restoration id on one of your navigation controllers. The graphic is from the state preservation and restoration guide developer.apple.com/library/ios/documentation/iphone/conceptual/…Tecla
See possible duplicate question [here][https://mcmap.net/q/737540/-state-restoration-in-ios] which has a useful answer.Doridoria
M
1

I have not found why this message is printed in the console but I think it was some kind of bug in iOS. With the latest iOS 7 updates I do not get "Warning: Unable to create restoration in progress marker file" anymore.

The more interesting part is the black screen. It happens when you have a normal ViewController and a TableView inside. I had to create TWO outlets between view property of the ViewController and the base view (except the table view there is more views, that is the reason I had to use a generic view controller). There is one connection automatically with every ViewController so that was really strange. I assume it is again some kind of iOS bug.

Metcalfe answered 22/11, 2013 at 10:6 Comment(0)
T
3

Please make sure that you set a view controller as the initial view controller in your storyboard file. You will find this setting in the attributes inspector.

Attributes inspector of main scene in storyboard

UPDATE

It sounds like you may not have added a restoration ID to the navigation controller itself but instead may have set the restoration IDs on child view controllers. If this is the case you should add the restoration id to the missing controller(s).

The State Preservation and Restoration Guide

Tecla answered 2/10, 2013 at 3:19 Comment(5)
I have done this. Otherwise I will get black screen all the time. I get it only when I show a specific one modally.Metcalfe
I have only a NavController as my base and I have set its restoration id. img13.imageshack.us/img13/4611/amtw.pngMetcalfe
@EvgeniPetrov - Are the restoration id's in place for the tableview and other views that you want restored in addition to the controller level? This blog does a good example of deconstructing a sample (useyourloaf.com/blog/2013/05/21/…)Tecla
I do not keep any UIViews with state restoration. I just save data per viewcontroller and then restore the UI state from the data. Could this be the reason for this weird warning?Metcalfe
@EvgeniPetrov I would suggest adding the restoration id to the view being presented modally to see if that impacts the black screen effect.Tecla
M
1

I have not found why this message is printed in the console but I think it was some kind of bug in iOS. With the latest iOS 7 updates I do not get "Warning: Unable to create restoration in progress marker file" anymore.

The more interesting part is the black screen. It happens when you have a normal ViewController and a TableView inside. I had to create TWO outlets between view property of the ViewController and the base view (except the table view there is more views, that is the reason I had to use a generic view controller). There is one connection automatically with every ViewController so that was really strange. I assume it is again some kind of iOS bug.

Metcalfe answered 22/11, 2013 at 10:6 Comment(0)
C
1

Adding the

UIViewControllerRestoration

solved it for me. If you click on the protocol reference it says :

// A class must implement this protocol if it is specified as the restoration class of a UIViewController.


@import UIKit;

@interface AppDelegate : UIResponder <UIApplicationDelegate, UIViewControllerRestoration>

@property (strong, nonatomic) UIWindow *window;

@end

In the docs it is written:

A restoration class implements the UIViewControllerRestoration protocol and is responsible for finding or creating a designated object at restore time. Here are some tips for when to use each one:

1) If the view controller is always loaded from your app’s main storyboard file at launch time, do not assign a restoration class. Instead, let your app delegate find the object or take advantage of UIKit’s support for implicitly finding restored objects.

2) For view controllers that are not loaded from your main storyboard file at launch time, assign a restoration class. The simplest option is to make each view controller its own restoration class.

So far I have understood it this way. Without the UIViewControllerRestoration protocol the appDelegate is not the restoration class (1). The warning is therefore written at the app start (restore time). The app delegate can not somehow find the object that needs to be assigned to the marker file. The problem is in the appDelegate. When the app delegate becomes the restorationClass it skips step 1) and goest to step 2). It seems that the appDelegate becomes the main restorationClass for all other views. The following method:

+ (UIViewController*) viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents
                                                            coder:(NSCoder *)coder {}

is never called in my app and the restoration works without warinings or errors.

I would like to understand the problem and what is going on. I hope this helps you, and comments are welcome to clarify the problem. :)

Cominform answered 16/12, 2014 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.