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. :)