records(continuingMatchFrom:desiredKeys:resultsLimit:)
Retrieves the next batch of records from an existing search and returns them to an awaiting caller.
Declaration
func records(continuingMatchFrom queryCursor: CKQueryOperation.Cursor, desiredKeys: [CKRecord.FieldKey]? = nil, resultsLimit: Int = CKQueryOperation.maximumResults) async throws -> (matchResults: [(CKRecord.ID, Result<CKRecord, any Error>)], queryCursor: CKQueryOperation.Cursor?)Parameters
- queryCursor:
The cursor that identifies, within the full search results, the location of the next subset of results to retrieve.
- desiredKeys:
The fields to include on each fetched record. To include all fields, specify
nil; to fetch only system fields, specify an empty array. - resultsLimit:
The maximum number of records to return in a single set of results.
Return Value
A tuple with the following named elements:
matchResultsAn array of tuples. Each tuple includes a record identifier and a Result that contains either the corresponding matched record, or an error that describes why CloudKit can’t provide that record. For example, if CloudKit fails to materialize an asset field, it returns an error instead of a partial record. CloudKit sorts the array according to the query’s sort descriptors.
queryCursorA cursor if the number of results exceeds
resultsLimit; otherwise,nil.
Discussion
If you specify resultsLimit and the number of matched records exceeds that value, this method returns only that number of records and a cursor — an object that marks a specific location in the full search results. To retrieve the next subset of search results, execute this method again and pass the returned cursor from previous execution. This method throws an error if the request fails, such as when the network is unavailable or the device doesn’t have an active iCloud account; otherwise, the returned tuple includes any individual record errors.
For information on a more configurable way to search a database, see CKQueryOperation.