ios - Error when passing data from one view controller to the other -


i'm making rss feed reader in swift 2 , i'm having hard time trying pass url tableview web view. when print url in tableviewcontroller adds (optional) in front of url. when has passed webviewcontroller has no (optional) inf front of it. makes me worry on fact has gone wrong on way.

tableviewcontroller passing url webviewcontroller:

    override func tableview(tableview: uitableview,     didselectrowatindexpath indexpath: nsindexpath){           let webvc = webviewcontroller()         webvc.entryurl = entriesarray[indexpath.row]["link"]          self.navigationcontroller?.pushviewcontroller(webvc, animated: true)         print(entriesarray[indexpath.row]["link"])   } 

webviewcontroller receiving data , trying use it:

    var entryurl:string!  override func viewdidload() {     super.viewdidload()     print(entryurl)      if entryurl != nil {     print(entryurl)     let requesturl: nsurl? = nsurl(string: entryurl)      let request = nsurlrequest(url: requesturl!)      web.loadrequest(request)      }     loadaddressurl() }  override func viewwilldisappear(animated: bool) {     super.viewwilldisappear(animated)      uiapplication.sharedapplication().networkactivityindicatorvisible = false }   func loadaddressurl() {     if let requesturl = nsurl(string: entryurl) {         let request = nsurlrequest(url: requesturl)         web?.loadrequest(request)     } } 

i error on line:

loadaddressurl() 

saying:

exc_bad_instruction (code=exc_i386_invop, subcode=0x0) on dispatch_semaphore_dispose 

from tableviewcontroller log prints: optional("http://www.google.com/")

but webviewcontroller log prints: http://www.google.com/

and after that: fatal error: unexpectedly found nil while unwrapping optional value

why won't work , why the url not optional anymore in webviewcontroller?

change line of code declare object of view controller below.

override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath){       let mainstoryboard: uistoryboard = uistoryboard(name: "main", bundle: nil)      let webvc = mainstoryboard.instantiateviewcontrollerwithidentifier("webviewcontroller") as! webviewcontroller      webvc.entryurl = entriesarray[indexpath.row]["link"]      self.navigationcontroller?.pushviewcontroller(webvc, animated: true)     print(entriesarray[indexpath.row]["link"])   } 

dont forgot add indetifier of viewcontroller in storyboard.

enter image description here


Comments