vikzilla
vikzilla

Reputation: 4138

recordFetchedBlock on CKQueryOperation not being called

I need to query for CKRecords of the recordType "Event". When I call recordFetchedBlock, I will add those records to my array. However, recordFetchedBlock is never getting called. Please help! Thank you:

    //TODO: Query for all Event records
    var database: CKDatabase = CKContainer.defaultContainer().privateCloudDatabase

    let truePredicate = NSPredicate(value: true)
    let eventQuery = CKQuery(recordType: "Event", predicate: truePredicate)

    let queryOperation = CKQueryOperation(query: eventQuery)

    queryOperation.recordFetchedBlock = { (record : CKRecord!) in

            self.eventsArray.append(record)
            println("recordFetchedBlock: \(self.eventsArray)")
    }

    queryOperation.queryCompletionBlock = { (cursor : CKQueryCursor!, error : NSError!) in

        println("queryCompletionBlock: \(self.eventsArray)")
    }

    database.addOperation(queryOperation)

Upvotes: 3

Views: 1993

Answers (1)

vikzilla
vikzilla

Reputation: 4138

So I just realized my error. I was accidentally calling the query on the private database (as opposed to the public). Currently kicking myself..

Upvotes: 4

Related Questions