ios - Swift and Parse - Message app, cannot display username within Xcode 6.3 -


i have issue display 'author's username of each posts in tableviewcontroller.

it display current user's username display posts, how display each poster's username ?

i'm using xcode 6.3 , parse.com api. timelabel displayed correctly, userlabel display current user logged in instead of author of post.

if logged out , login different username userlabel change new user. debug console display optional("thenameofthecurrentuser") many times there posts displayed.

parse host 2 db 1 users (user) , 1 posts (poemes), there pointer in poemes table specific user.

i update xcode 6.3 lately , had error on var findlover:pfquery = pfuser.query()

value of optional type 'pfquery?' not unwrapped

i add exclamation mark (!) @ end of line, remove error, causing issue ?

i read parse documentation , follow exemples looks i'm bit lost here, , suggestions highly appreciated, thanks.

override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     let cell:displaytableviewcell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! displaytableviewcell      let poeme:pfobject = self.timelinedata.objectatindex(indexpath.row) as! pfobject     cell.poemelabel.text = poeme.objectforkey("content") as? string      var dateformatter:nsdateformatter = nsdateformatter()     dateformatter.dateformat = "mm-dd hh:mm"     cell.timelabel.text = dateformatter.stringfromdate(poeme.createdat!)      var finduser:pfquery = pfuser.query()!     finduser.findobjectsinbackgroundwithblock {         (objects, error)->void in          if var objects = objects {              let author:pfuser = (objects nsarray).lastobject as! pfuser             cell.userlabel.text = author.username              println(author.username)          })     }      return cell } 

the function finduser.findobjectsinbackgroundwithblock happens in background, while main thread still running, time response parse values need cell trying return in function long gone.

the easiest way fix fetch data need before hand , safe in array , use array populate cell.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -