Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Error: Value of optional type 'UIViewController?' not unwrapped; did you mean to use '!' or '?'? #70

Closed
LukasGram opened this issue Sep 3, 2015 · 3 comments

Comments

@LukasGram
Copy link

One of my Storyboards uses an UIViewController without any custom class. After the Storyboard.swift is generated I get the error in the following function:

static func instantiateInitialViewController() -> UIViewController {
   return self.storyboard.instantiateInitialViewController()
}

I'm using the Swift 2.0 version of Natalie.

@krzyzanowskim
Copy link
Owner

ah, it changes between SDK versions, and differ in iOS and Mac. Need to double check this one.

@krzyzanowskim
Copy link
Owner

how come hm.... it should be something like this, with as!

        static func instantiateInitialViewController() -> UINavigationController {
            return self.storyboard.instantiateInitialViewController() as! UINavigationController
        }

@LukasGram
Copy link
Author

In one of my Storyboards the initial view controller is an UIViewController.
But self.storyboard.instantiateInitialViewController() as! UIViewController would not make sense since instantiateInitialViewController() returns UIViewController?
So it needs to look like this: self.storyboard.instantiateInitialViewController()!

Already created a pull request (#71) which should fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants