'How to limit the number of returned records using CloudKit framework?

Is there any way to limit the number of records returned from a query using CloudKit framework? E.g. only return the latest value by sorting it by date (already figured that out) but then limit the returned records to 1?



Solution 1:[1]

Yes, use a CKQueryOperation and it's resultsLimit property.

resultsLimit

The maximum number of records to return at one time.

Discussion

For most queries, leave the value of this property as the default value, which is the maximumResults constant. When using that value, CloudKit returns as many records as possible while minimizing delays in receiving those records. If you want to process a fixed number of results, change the value of this property accordingly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 malhal