如何从Parse查询中获得超过1000个结果?

时间:2015-09-09 17:25:45

标签: ios iphone swift parse-platform

我一直试图取得成功。初步查询后,我尝试计算结果。然后,我检查结果是否等于查询的限制。如果它们相同,我创建一个新查询并重复。

然而,我得到的只是第一个查询的结果。

代码在这里:

  var allObjects = [PFObject]()

    var skip = 0
    var limit = 10

    var downloadCards = PFQuery(className: "Checklist")
    downloadCards.whereKey("createdBy", equalTo:PFUser.currentUser()!)
    downloadCards.includeKey("card")
    downloadCards.orderByAscending("IndexNumber")
    downloadCards.limit = limit
    downloadCards.skip = skip
    downloadCards.findObjectsInBackgroundWithBlock {
        (objects: [AnyObject]?, error: NSError?) -> Void in
        if error == nil {

            if let objects = objects as? [PFObject] {
                for object in objects {
                    if let card = object["card"] as? PFObject {
                        allObjects.append(card)
                    }
                }
            }

//1000
                if objects!.count == limit {
                    //Query again until results aren't equal to limit
                    skip = skip + limit
                    var downloadCards2 = PFQuery(className: "Checklist")
                    downloadCards2.whereKey("createdBy", equalTo:PFUser.currentUser()!)
                    downloadCards2.includeKey("card")
                    downloadCards2.orderByAscending("IndexNumber")
                    downloadCards2.limit = limit
                    downloadCards2.skip = skip
                    downloadCards2.findObjectsInBackgroundWithBlock {
                        (objects: [AnyObject]?, error: NSError?) -> Void in
                        if error == nil {

                            if let objects = objects as? [PFObject] {
                                for object in objects {
                                    if let card = object["card"] as? PFObject {
                                        allObjects.append(card)
                                    }
                                }
                            }

0 个答案:

没有答案