ios - Can't UnWrap Optional - None Swift -


i assure have checked answers prior posting question on unwrapping object, thing not seem work me. trying pass on text value cell tapped label on next screen.

override func prepareforsegue(segue: uistoryboardsegue!, sender: anyobject!) {      if(segue.identifier == "detailviewsegue")     {         var dvc:detailedviewcontroller = segue.destinationviewcontroller detailedviewcontroller         let path:nsindexpath = self.tableview.indexpathforselectedrow()         var seguerecipename:string = recipemgr.recipename[path.row] string         dvc.detailedrecipelabel.text = seguerecipename         }  } 

the problem occurs @ line -

dvc.detailedrecipelabel.text = seguerecipename //can't unwrap optional - none 

i know i'm supposed check nil value of seguerecipename before assigning. print check on console , not null. error occurs when i'm assigning value 2nd view controller class object. i'm sure others learning swift :)

dvc.detailedrecipelabel nil

probably it's iboutlet hasn't been loaded yet.

you should add custom property detailedviewcontroller accept text, save , can assign label in viewdidload.

example:

class detailedviewcontroller ... {   ...   var recipename: nsstring? = nil    ...    override func viewdidload() -> () {      ...      self.detailedrecipelabel.text = self.recipename   } }    


dvc.recipename = seguerecipename 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -