ios - [Solved]Segue pushing Nothing first time(delay in data sent) -


hello stackoverflow, i'm picking swift , trying implement data being passed between uitableview cell uiviewcontroller show detailed view of info shown on tableview, , whenever test application on emulator first time press table cell passes empty string , when try pressing cell viewcontroller shows string supposed seen earlier.i pasted code have tableview didselectrowatindexpath below.

    override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {         tableview.deselectrowatindexpath(indexpath, animated: false)         var7 = lat[indexpath.item]         var6 = long[indexpath.item]         var5 = items[indexpath.item]         var1 = detail[indexpath.item]         var2 = date[indexpath.item]         var3 = wop[indexpath.item]         var4 = viewcontroller()         nextview.locationpassed = var1          //self.performseguewithidentifier("detailpush", sender: self)         println("value stored in var1: \(var1)")         //println("the selected indexpath \(indexpath.item + 1)")         println("the stored id is: \(storesend)") } 

here implementation push segue method

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     if segue.identifier == "detailpush"     {         if let crimesview = segue.destinationviewcontroller as? viewcontroller {             crimesview.locationpassed = var1             //println("the passing address is: \(var1)")         }     }  } 

any idea on why i'm getting data delayed during segue?

thank you

solution found: edited prepareforsegue method following , fixed issue

    override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {      //adding indexpath variable selected table row within segue     var indexpath: nsindexpath = self.tableview.indexpathforselectedrow()!      if segue.identifier == "detailpush"     {             if let crimesview = segue.destinationviewcontroller as? viewcontroller {                 //then pass data corresponding array created identified index of selected row                 crimesview.locationpassed = self.arrayname[indexpath.row]                 println("the passing address is: \(self.addresssend)")             }     }   } 

i found solution watching online videos , did fix issue redefine prepareforsegue function with:

 override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {  //adding indexpath variable selected table row within segue var indexpath: nsindexpath = self.tableview.indexpathforselectedrow()!  if segue.identifier == "detailpush" {         if let crimesview = segue.destinationviewcontroller as? viewcontroller {             //then pass data corresponding array created identified index of selected row             crimesview.locationpassed = self.arrayname[indexpath.row]             println("the passing address is: \(self.addresssend)")         } } 

}

and seems work regular segue me.......thank suggestions given me


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -