ios - XCode 6: I can't select a view by its storyboard ID -


this code :

let theboard = self.storyboard! let vc = theboard.instantiateviewcontrollerwithidentifier("myviewid")  as! uiviewcontroller // line causes error 

the second line causes error:

unexpectedly found nil while unwrapping optional value 

* important * : error fires when build configuration set "debug". works when set "release".

why ?

you casting uiviewcontroller in let vc = theboard.instantiateviewcontrollerwithidentifier("myviewid") as! uiviewcontroller wrong. should try:

var storyboard = uistoryboard(name: "main", bundle: nil)  var vc = storyboard.instantiateviewcontrollerwithidentifier("myviewid") as! viewcontroller 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -