stuart-d2
4/21/2015 - 4:31 PM

didFinishLaunchingWithOptions Method : Setting Root View Controllers in AppDelegate Single VC instances and Multiple VC instances

didFinishLaunchingWithOptions Method : Setting Root View Controllers in AppDelegate Single VC instances and Multiple VC instances

/*
application:didFinishinLaunnchingWithOptions method
Found in appdelegate.
More information, see hypnoNerdStu repo, appdelegate
• Where you instantiate and set a applications root view controller
• Called exactly once when app is launched.

Notice here there are commented out line.
THe first iteration was setting a simple root view controller
e.g., for the hypnosis view 
The second iteration the tab bar controller is set 
as the root view controller.  


*/

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    //Creating a instance of the VC -- for the hypnosis view 
    BNRHypnosisViewController *hvc = [[BNRHypnosisViewController alloc] init];

    //A pointer to an object that represents the app bundle
    NSBundle *appBundle = [NSBundle mainBundle];

    //root view controller 
    //Look in the appBundle for the file BRNRemiinderViewController.xib
    BNRReminderViewController *rvc = [[BNRReminderViewController alloc] initWithNibName:@"BNReminderViewController" bundle:appBundle];
   
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    tabBarController.viewControllers = @[hvc, rvc];

    //setting the root view controller
    //changed the window rvc from hypnosis VC to the tabBarController.
   // self.window.rootViewController = hvc;
    self.window.rootViewController = tabBarController;

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];  
    return YES;
}