CloudKit CKQueryOperation doesn't get all records

白昼怎懂夜的黑 提交于 2019-12-05 02:34:09

问题


In CloudKit RecordType is more than 100 records. Following code gets from these only 11 and they are not first 11 records, they are picked randomly from beginning, center and at the end of records. I can't get whats wrong in code.

EDIT : I got it working by changing .reseltsLimit to 5000!

let cloudContainer = CKContainer.default()
        let publicDatabase = cloudContainer.publicCloudDatabase
        let predicate = NSPredicate(value: true)
        let query = CKQuery(recordType: "Sijainti", predicate: predicate)

        var queryOperation = CKQueryOperation(query: query)
        queryOperation.queuePriority = .veryHigh
        queryOperation.resultsLimit = 50
        queryOperation.desiredKeys = ["Koordinaatit"]

        queryOperation.recordFetchedBlock = { (record) -> Void in
            self.sijainnitArray.append(record)
        }

        queryOperation.queryCompletionBlock = { (cursor, error) -> Void in

            if error != nil {
                print("Failed to get data")
                return
            }

            if cursor != nil {
                let newQueryOperation = CKQueryOperation(cursor: cursor!)
                newQueryOperation.cursor = cursor
                newQueryOperation.resultsLimit = queryOperation.resultsLimit
                newQueryOperation.queryCompletionBlock = queryOperation.queryCompletionBlock

                queryOperation = newQueryOperation

                publicDatabase.add(queryOperation)
                return

            }
        }

        publicDatabase.add(queryOperation)

来源:https://stackoverflow.com/questions/40847040/cloudkit-ckqueryoperation-doesnt-get-all-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!