swift - Parse get data with block not assigning value to variable in scope -


having issues assign uiimagefile = image!. if try assign self.myimage = image! myimage global variable works.

is possible done?

the code retrieving images ok, cell take image if pointed directly. bridge not working. , not work image.

also following test line println("teststring\(indexpath.row)") above return being able , print value teststring = "\(indexpath.row)" inside getdatainbackgroundwithblock.

sorry question title. not sure how resume issue in single sentence.

    func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {          let cellidentifier = "cell"         let cell = tableview.dequeuereusablecellwithidentifier(cellidentifier, forindexpath: indexpath) as! hobbiefeedtableviewcell         let object: pfobject = self.timelinedata.objectatindex(indexpath.row) as! pfobject          var mytext = object.objectforkey("posttext") as? string          let userimagefile = object.objectforkey("postimage") as? pffile         var uiimagefile = uiimage()         var teststring = string()          println(userimagefile, indexpath.row)          if userimagefile != nil {             userimagefile?.getdatainbackgroundwithblock({ (imagedata:nsdata?, error:nserror?) -> void in                 if error == nil {                      if let myimagedata = imagedata {                         let image = uiimage(data:myimagedata)                         self.myimage = image!                         uiimagefile = image!                         teststring = "\(indexpath.row)"                     }                 }                 }, progressblock: { (percent: int32) -> void in             })         }          cell.celltitle.text = mytext         cell.cellimage.image = uiimagefile //                cell.cellimage.image = myimage          println("teststring\(indexpath.row)")         return cell     } 

cell.cellimage.image = uiimagefile

gets executed before uiimagefile has been retrieved. because

getdatainbackgroundwithblock returns right away before retrieval done.

you can fix by: (1) retrieve images local array in viewdidload function (2) use push notification on completion on retrieval trigger tableview.reload


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -