1

My segue is returning with an error (unwrapping an optional value) from this line > self.navigationController?....

In my code...

let nextScreen = self.storyboard!.instantiateViewControllerWithIdentifier("onboarding-what") as? ViewController
        self.navigationController?.pushViewController(nextScreen!, animated: true)

This above code is implemented in my onboarding-start view controller

This is my storyboard set up...enter image description here

the last view controller has the id of "onboarding-what".

I've read the documentation for the navigation controller but can't seem to find my problem. Does anyone have a solution?

Community
  • 1
  • 1
Liam Shalon
  • 422
  • 2
  • 5
  • 19

2 Answers2

1

Obviously nextScreen is nil. It is most likely that "onboarding-what" identifier is incorrect

Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
1

You can use performSegueWithIdentifier rather than pushViewController if you connected them in storyboard

However did you fill "onboarding-what" in the storyboardId field? pls check this image

Also "onboarding-what" view controller should be instance of ViewController (There's not default class called "ViewController" only "UIViewController" or "NSViewController" for osX.)

Alex
  • 616
  • 4
  • 11