ios - Issue when passing Data through segue in swift -


i know question has been answered not solve issue. issue when passing data through segue returns nil in destination viewcontroller. let have defined news() object , 3 string object in destination viewcontroller setting in segue method got nil in destination viewcontroller.

class newsdetailviewcontroller: uiviewcontroller {     var objnews = news();     var newstime: string?     var newsdetail: string?     var imageurl: string?  // rest of class . . } 

and here segue method

    override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     // pass selected object new view controller.     if segue.identifier == "seguenewsdetail" {         var ndvc = newsdetailviewcontroller();         var indexpath: nsindexpath = self.tblviewstudent.indexpathforselectedrow()!         var tempobj = self.news.objectatindex(indexpath.row) news         ndvc.objnews = (self.news.objectatindex(indexpath.row) news)         ndvc.newstime = tempobj.created_at;         ndvc.newsdetail = tempobj.newsdescription;         ndvc.imageurl = tempobj.imageurl;          println("\(ndvc.newstime) \(ndvc.newsdetail) \(ndvc.imageurl)")      } 

when try log values in segue method check if values setting or not (these value setting desired values, mean don't nil here in segue method):

println("\(ndvc.newstime) \(ndvc.newsdetail) \(ndvc.imageurl)") 

i tried many option failed. please help..

thanks in advance

change

var ndvc = newsdetailviewcontroller() 

to

let ndvc = segue.destinationviewcontroller as! newsdetailviewcontroller 

btw don't need semicolon in swift


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -