0

In my storyboard I have´t got any view like initialViewController but I have storyboard, I want choose that depends if is Logged or not for example.

I have in the AppDelegate

func application(application: UIApplication, didFinishLaunchingWithOptions: [NSObject: AnyObject]?) -> Bool
    { 
let storyboard = UISToryboard(name: "Main", bundle: nil)
if isLogged{
//Access to DatesViewController
let vc = storyboard.instantiateViewControllerWithIdentifier("dates")
self.window?.rootViewController?.presentViewController(vc, animated:true,completion: nil)


}else{
//Access to LoginViewController
let vc = storyboard.instantiateViewControllerWithIdentifier("login")
    self.window?.rootViewController?.presentViewController(vc, animated:true,completion: nil)
}
self.window?.makeLeyAndVisible()
return true

I don´t know how to do that, there is very much information for objetiveC but no for Swift.

This don´t work the error is: *

Failed to instantiate the default view controller for UIMainStoryBoardFile 'Main' -perhaps the designated entry point is not set?

*

If you can help me please Thanks!


This work:

func application(application: UIApplication, didFinishLaunchingWithOptions: [NSObject: AnyObject]?) -> Bool
    { 
let storyboard = UISToryboard(name: "Main", bundle: nil)
if isLogged{
//Access to DatesViewController
var vc = self.window?.rootViewController?.storyboard?.instantiateViewControllerWithIdentifier("dates")
self.window?.rootViewController = vc 


}else{
//Access to LoginViewController
var vc = self.window?.rootViewController?.storyboard?.instantiateViewControllerWithIdentifier("login")
self.window?.rootViewController = vc 
}
self.window?.makeLeyAndVisible()
return true
lau_ga
  • 21
  • 1
  • I try to aply your link but don´t works in AppDelegate, and it isn´t a duplicate because I use a storyboard and that question that they say that is duplicate don´t use. Thanks! – lau_ga Apr 27 '16 at 00:24
  • Voted to reopen because this question very obviously has a storyboard, while the one linked to very obviously does not. This question will definitely be a duplicate, but not of the one linked to – Gruntcakes Apr 27 '16 at 01:11

0 Answers0