title: How to change RootViewController programmatically?
body: <p>I am developing some custom camera app, I just want to skip my login page and make my camera home page to initial root view when  user already registered. I'm doing it from AppDelegate or inside the view code however I'm getting an error any one described it from scratch or any sample example. My code is below,</p>
  
  <p>Codes are in <code>viewDidLoad</code></p>
  
  <p>If I am trying below code in <code>AppDelegate</code> then also its occurs problem</p>
  
  <pre><code>UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main.storyboard" bundle:[NSBundle mainBundle]];
  
  NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  if (![defaults boolForKey:@"registered"])
  {
      NSLog(@"no user register");
  
      ViewController *loginview = [storyBoard instantiateViewControllerWithIdentifier:@"ViewController"];
      self.window.rootViewController = loginview;        
  }
  else
  {        
      NSLog(@"user is registered");
  
      CameraHome *camview = [storyBoard instantiateViewControllerWithIdentifier:@"CameraHome"];
      self.window.rootViewController = camview;
  }
  </code></pre>
  
  <p>Any one can please describe how to skip that view if I'm already registered and switch directly to my homepage.</p>