0

I am trying to add to my app delegate file the code that will allow me to segue directly to my "Camera VC" if the user is logged in and to the "loginVC" if the user is not logged in. To be honest, I am very lost on how to do this and any help would be hugely appreciated.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    var isLoggedIn: Bool?

    let storyboardId: String = (isLoggedIn != nil) ? "loginVC" : "CameraVC"

    self.window?.rootViewController?.storyboard?.instantiateViewControllerWithIdentifier(storyboardId as String)

    return true
}
Jamie Baker
  • 157
  • 6

2 Answers2

0

In Storyboard each UIViewController has flag to be initialViewController.U need to set it right. Imho best solution is to wrap both controllers in some container controller (ie UINavigationController) and programatically push (pop) to write contained UIViewController.

Tomas Cejka
  • 96
  • 1
  • 8
0

example in objC

if(![SettingsUtility isUserAuthorized])
    {
        [self showLoginViewController];
    }

    -(void)showLoginViewController
    {
        [self.navigationController performSegueWithIdentifier:@"showLoginViewController" sender:self];
    }
Tomas Cejka
  • 96
  • 1
  • 8
  • Tomas Cejka, you can always edit your original answer to add any additional code, clarification, etc. I know that code won't format well in the comments, which is why you probably added the second answer, but you should just go back and edit your original answer and add the code there so there's a single answer that can be marked correct / upvoted / commented / etc. – xdeleon Dec 08 '15 at 16:28
  • Thx for feedback... Im quite new active user I used to be passive for a long time. Im still learning adding comments so they look like as i want. I will do next time as u write.... – Tomas Cejka Dec 08 '15 at 17:41