Swift 4.2 iOS 11.x
I must have missed something cause this surely should work. I got this code that queries the private database in a custom zone. It returns nothing despite the fact that I have records there. I added indexes to everything! I also changed the roles in permissions so that any authenticated user could read records.
public func cleanUpImages(zone2U:String) {
var records2Delete:[CKRecord.ID] = []
let zone2D = CKRecordZone(zoneName: zone2U)
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: remoteRecords.notificationMedia, predicate: predicate)
let operation = CKQueryOperation(query: query)
operation.recordFetchedBlock = { record in
records2Delete.append(record.recordID)
}
operation.queryCompletionBlock = { cursor, error in
print(records2Delete.count)
}
CKContainer.default().privateCloudDatabase.add(operation)
notificationMedia is a global static var that I also use to save said records, so it cannot be wrong/different.
Set the
zoneID
ofoperation
because right now you are querying the default zone.