2

My app has four states each using its own root view controller and I only need to restore the views for the online state but need to go through the three other states on startup for doing the login and loading the app content.

I have it working for a simple app based on the UITabBarController which works perfectly. But there I can instantiate the view controllers in the application:willFinishLaunchingWithOptions: without a problem as I always have the same.

I'm struggling to move this concept over from the static number of view controller example to the dynamic context of my real application.

What I would like to have is some sort of delayed instancing of my view controllers so they are instantiated once the session context is recreated. But as far as I see this is not possible with the api.

I think my conceptual problem is that at the moment when application:viewControllerWithRestorationIdentifierPath:coder: the login to the server is not yet done. So I cannot setup my dao objects to load the dynamic content I would need to create the view controllers.

Shorty I was also thinking about just saving the dynamic data from the server with the app state so I could redisplay it, and then do the login behind the scene and merge the data with the real data from the server. But this approach does sound hacky and merging the data displayed with the real data from the server also creates a lot of issues. And it is discouraged by the documentation as well.

At the moment I'm actually thinking to record all calls to the application:viewControllerWithRestorationIdentifierPath:coder: method and record the data so I could use it later when I'm ready to create the actual view controllers, but I have the feeling that this is not the intention on how to use this api.

Does anybody have some direction for me?

4

0 回答 0