parse.com - Getting parse object for specific key in swift -


i succeeded in saving event specific user in parse, haven't quite figured out how them out populate table view in different view controller, "my events" table view user can see events created.

how can table view populate image , title of event? there event class keys "image" , "title" in order events of specific user have go through user class , query "events" key.

sorry if little confusing , there isn't code go off, if further explanation needed that's not problem. thanks!

import uikit import parse  class calenderviewcontroller: uiviewcontroller, uitableviewdatasource,     uitableviewdelegate {  var eventstoattend : [event]? = [] var user = pfuser.currentuser() var responseobjects : [anyobject]? = []  @iboutlet weak var eventstableview: uitableview!  override func viewdidload() {     super.viewdidload()      var query = pfuser.query()     query?.includekey("events")      query?.findobjectsinbackgroundwithblock({ (objects, error) -> void in          self.responseobjects = objects  //            self.responseobjects = query?.findobjects()      })   }  func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {      var cell : uitableviewcell = tableview.dequeuereusablecellwithidentifier("cell") as! uitableviewcell      user?.objectforkey("events")      cell.textlabel?.text       return cell  }  func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {  //        if let eventstoattend = self.eventstoattend { //            return eventstoattend.count //        }      return responseobjects!.count }  func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {   } 

parse has done heavy lifting here, can use pfquerytableviewcontroller class , populate event objects. see here how use it: https://parse.com/docs/ios/api/classes/pfquerytableviewcontroller.html , tutorial: http://blog.parse.com/learn/engineering/loading-remote-images-in-a-table-view/

you can embed pfquerytableviewcontroller view controller if like. if need start doing special things edits , deletes (or hiding) starts becoming better roll own implementation.

if still want try code started with, here missing:

1) in cellforrowatindexpath method, use indexpath.row correct event object self.responseobjects (assuming there single section).

2) using event object have gotten in step one, assign title property cell.textlabel?.text.

3) assuming event.image property pffile, need load pffile async, in callback create new image bytes, assign new image cell.imageview.image property.


Comments