Home > Mobile >  How to limit the number of returned records using CloudKit framework?
How to limit the number of returned records using CloudKit framework?

Time:05-09

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?

CodePudding user response:

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.

  • Related