title: IOS login required for certain tabs with storyboard
body: <p>My question is based on the following question, but my case is reversed.</p>
  
  <p><a href="https://stackoverflow.com/questions/16351348/example-for-login-screen-modally-based-on-storyboard">Example for login screen modally based on storyboard</a></p>
  
  <p>I would like to have a few tabs private for users only so required login, my storyboard is below:
  <img src="https://i.stack.imgur.com/rfmtM.png" alt="enter image description here"></p>
  
  <p>Below is my code in custom tabBarController</p>
  
  <pre><code>@interface PNTabBarController ()
  
  @end
  
  @implementation PNTabBarController
  
  - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
  {
      NSUInteger indexOfTab = [tabBar.items indexOfObject:item];
      NSLog(@"%lu", (unsigned long)indexOfTab);
      if (indexOfTab == 2 || indexOfTab == 3) {
          PFUser *currentUser = [PFUser currentUser];
          NSLog(@"%@", currentUser.username);
          if(currentUser == nil){          
              PNLoginViewController *obj = [[PNLoginViewController alloc]init];
              [self presentViewController:obj animated:YES completion:NULL];
          }
          else{
              NSLog(@"%@", currentUser.username);
          }
      }
  }
  </code></pre>
  
  <p>But what happens is a dark screen when I click the 2 or 3 tab. What should be the correct way to achieve this?</p>