Im trying fetch records from my private CloudKit DB.I could able to fetch the record.I stucked in accessing the fetched record
func ReadRecord() {
let predicate = NSPredicate(format: "name = %@", "samsung")
let query = CKQuery(recordType: "MobileDetails", predicate: predicate)
let operation = CKQueryOperation(query: query)
print("Operation Result is \(operation)")
var items: [Mobile] = []
operation.recordMatchedBlock = { (recordID,record) in
switch record{
case .success(let record):
print("Success Case")
items.append(Mobile(name: record["name"] as! String, price: record["price"] as! String))
case .failure(let error):
print("Error Occured")
}
}
operation.queryResultBlock = { result in
DispatchQueue.main.async{
self.Array = items
}
}
privateDatabase.add(operation)
print("Array count is \(Array.count)")
}
This is my function to fetch a record
The recordmatchedBlock is not at all executing and I'm getting only the empty array in the queryResult block
Also tried the query CompletionBlock that too doesn't work