Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Simen Anthonsen
1,097 PointsCloudKit query only returns 300 records
My CloudKit query only return 300 records when i have about 500. This is my code
func getCloudKitMoviesData(viewController: UIViewController) {
let cloudContainer = CKContainer.defaultContainer()
let publicDatabase = cloudContainer.publicCloudDatabase
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "Movies", predicate: predicate)
let queryOperation = CKQueryOperation(query: query)
queryOperation.desiredKeys = ["Title", "Rating", "Genre"]
queryOperation.queuePriority = .VeryHigh
queryOperation.recordFetchedBlock = {
(record: CKRecord!) -> Void in
if let movieRecord = record {
movies.append(movieRecord)
}
}
queryOperation.queryCompletionBlock = {
(cursor:CKQueryCursor?, error: NSError?) -> Void in
if cursor != nil {
let newOperation = CKQueryOperation(cursor: cursor!)
newOperation.recordFetchedBlock = {
(record: CKRecord!) -> Void in
if let movieRecord = record {
movies.append(movieRecord)
}
}
newOperation.queryCompletionBlock = queryOperation.queryCompletionBlock
publicDatabase.addOperation(newOperation)
}
}
publicDatabase.addOperation(queryOperation)
}