How to get records with specific identifiers?

I can easily get a record with a specific id. If I need something specific, then I can use CKQueryOperation.

I need to provide it with the correct predicate, but I cannot specify identifiers as a predicate parameter, because it does not support the CKRecordValue protocol. Another idea is to use CKReference, but how to write the correct predicate?

If I try to use an array of strings and again evaluate the path to write recordID.recordName:

    var references:[String] = IDs.map{$0.recordName}
    var predicate = NSPredicate(format: "ANY recordID.recordName IN %@", references)

I get the following error:

<CKError 0x17005f3b0: "Invalid Arguments" (12/1009); "Invalid predicate: recordKey (recordID.recordName) contains invalid characters">

Predicate format output:

predicate ANY recordID.recordName IN {"AFF487BE-4A7E-4F76-8185-79FA2E1EFC33", "D4D83B37-97DE-4BF2-9E43-4C5522E36DF1", "0126008A-0B42-4F95-AB31-BB13B6215475", "6DE83AD9-F307-467D-A5EF-AD2B97B8E7F7", "F701ADBF-9BE7-4F42-8CA9-44D2D0E629F8", "38C4FB60-8A65-43F9-8E1E-4C48D5B60DCD"}

Any help is appreciated.

+4
source share
1 answer

CKFetchRecordsOperation , RecordID, :

let fetchRecordsOperation = CKFetchRecordsOperation(recordIDs: recordIDs)
fetchRecordsOperation.desiredKeys = desiredKeys

CKRecordID, , perRecordCompletionBlock , fetchRecordsCompletionBlock.

, NSStrings desiredKeys , .

+3

Source: https://habr.com/ru/post/1548709/


All Articles