Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

recordFetchedBlock on CKQueryOperation not being called

Tags:

swift

cloudkit

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)
like image 723
vikzilla Avatar asked Apr 29 '26 23:04

vikzilla


1 Answers

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

like image 115
vikzilla Avatar answered May 01 '26 13:05

vikzilla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!