title: Change initial View Controller of Master-Detail-Application
body: <p>I created a new iPhone project on a Master-Detail-Application. As I need a login before, I added at the <strong>storyboard a new ViewController</strong>, checkmarked "<strong>is initial View Controller</strong>" and assigned the new created <strong>class LoginViewController</strong> to this ViewController.</p>
  
  <p><em>Furthermore but not relevant (in my opinion), i created a segue and connected it from the ViewController to the NavigationController (of the Master-Detail-Template).</em></p>
  
  <p>The <strong>AppDelegate.m</strong> was changed to launch the new controller at startup: </p>
  
  <pre class="lang-c prettyprint-override"><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      // Override point for customization after application launch.
  
      /* // Old Master-Detail-View-Controller
      UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
      MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
      controller.managedObjectContext = self.managedObjectContext;
       */
  
      (LoginViewController *)self.window.rootViewController;
  
      return YES;
  }
  </code></pre>
  
  <p>This will end up in the error: </p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
  reason: '-[UICollectionViewController loadView] loaded the "Qn5-Rj-iPA-view-IRE-eP
  -ILZ" nib but didn't get a UICollectionView.'
  </code></pre>
  
  <p>I have as well tried this: 
  </p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      // Override point for customization after application launch.
  
      LoginViewController *loginViewController = [[LoginViewController alloc] init];
  
      self.window.rootViewController = loginViewController;   //Set the view controller
      [self.window makeKeyAndVisible];
  
      return YES;
  }
  </code></pre>
  
  <p>Resulting in a similar error: </p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
  reason: 'UICollectionView must be initialized with a non-nil layout parameter'
  </code></pre>
  
  <p>Where is my mistake? </p>
  
  <p>What I do not get is, where the hell the <strong>UICollectionView</strong> in the error message comes from. I did never create one or add one??</p>
  
  <p><img src="https://i.stack.imgur.com/64nk1.png" alt="Storyboard"></p>