iosswiftparse-platformpfcollectionviewcell

Parse.com query.limit doesn't work in PFCollectionView


First, thanks for helping. I am writing an iOs application developed with Swift and i'm using Parse.com. In a class named liste_joueurs, there is around 15 rows. However, I just want to retrieve the first four results.

I read the docs and found the query.limit property. Unfortunately, when I run my code, in my collection, all the rows from my class appear (the query.limit doesn't work).

Does anyone have a solution ?

override func queryForCollection() -> PFQuery {
    let query = PFQuery(className: "liste_joueurs")
    query.limit = 4 // Useless
    query.orderByAscending("nom")
    return query
}

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFCollectionViewCell? {
    println(object["nom"]?.count)
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("statsCell", forIndexPath: indexPath) as! StatsViewCell

    // CELL'S TREATMENT  

    return cell
}

PS : When I used a constraint like this one :

query.whereKey("nom", hasPrefix: "ba")

The query "is filtered" and only rows beginning by "ba" appears in my collection...


Solution

  • With only this code I can say if you are using PFQueryCollectionViewController than make sure paginationEnabled = false, otherwise it will ignore. and if you are using objectsPerPage then it will override limit