ios - How can I populate a UICollectionView with a Parse array of objectIds? -


i using parse.com. have array(named "wants" of objectids want use populate uicollectionview each objectid's corresponding image. i'm not quite sure start.

i tried using pfquery wherekey of "wants", i'm not sure put in "equalto" parameter.

        var downloadcards = pfquery(classname: "user")         downloadcards.wherekey("wants", equalto:"")         downloadcards.orderbyascending("number")         downloadcards.limit = 200         downloadcards.findobjectsinbackgroundwithblock {              (objects: [anyobject]?, error: nserror?) -> void in             if error == nil {                 if let objects = objects as? [pfobject] {                     object in objects {                         objectids.append(object.objectid!)                         parseobjects.append(object["image"] as! pffile)                         imagenames.append(object["number"] as! string)                         imageexpansions.append(object["expansionnumber"] as! string)                         self.collectionview.reloaddata()                     }                 }             } else {                 println("error: \(error!) \(error!.userinfo!)")             }         } 

collection view code here:

func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int {      return parseobjects.count  }  func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {      let cell: cardscollectionviewcell = collectionview.dequeuereusablecellwithreuseidentifier("cell", forindexpath: indexpath) as! cardscollectionviewcell      parseobjects[indexpath.row].getdatainbackgroundwithblock{          (imagedata: nsdata?, error: nserror?) -> void in          if error == nil {              let image = uiimage(data: imagedata!)              cell.cardsimg.image = image          }         }     return cell } 

yes can function

// initialise pfquerytable tableview override init!(style: uitableviewstyle, classname: string!) {     super.init(style: style, classname: classname) }  required init(coder adecoder: nscoder) {     super.init(coder: adecoder)      // configure pfquerytableview     self.parseclassname = "yourclass"      self.textkey = "yourobject"     self.pulltorefreshenabled = true     self.paginationenabled = false } 

is async collectionview function returning empty cell. easiest way around download data , update collection view


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 -