I'm currently working on an app that will be using multiple story boards as follows:
1) login.storyboard (handles registration and login)
2) main.storyboard (handles game options and selection)
3) settings.storyboard (handles settings for game(s))
4) game.storyboard (actualy game play)
I currently test for a session token in NSUserDefaults and if it exists, load the main.storyboard otherwise auth.storyboard using:
NSUserDefaults *tagDefaults = [NSUserDefaults standardUserDefaults];
if (![tagDefaults objectForKey:@"session_token"]) {
NSLog(@"session token not found");
NSString *storyboardId = @"nonauth";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"login" bundle:nil];
UIViewController *initViewController = [storyboard instantiateViewControllerWithIdentifier:storyboardId];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initViewController;
[self.window makeKeyAndVisible];
} else {
NSString *storyboardId = @"init";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"init" bundle:nil];
UIViewController *initViewController = [storyboard instantiateViewControllerWithIdentifier:storyboardId];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initViewController;
[self.window makeKeyAndVisible];
}
from the login screen if the login return is valid I use this to switch from login.storyboard to main.storyboard in my NSURLSession completion handler:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"main" bundle:nil];
UINavigationController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"main"];
self.view.window.rootViewController = viewController;
My two questions are: A) is this the correct way to implement this? B) There is a considerable delay after executing the switch from login.storyboard before main.storyboard actually loads (20-30 seconds of delay), is there a way to speed this up or improve the code to avoid this delay?
Thanks in advance.
J