Is there any way to limit the amount of results that are returned in a CKQuery
?
In SQL
, it is possible to run a query like SELECT * FROM Posts LIMIT 10,15
. Is there anything like the last part of the query, LIMIT 10,15
in CloudKit?
For example, I would like to load the first 5 results, then, once the user scrolls down, I would like to load the next 5 results, and so on. In SQL, it would be LIMIT 0,5
, then LIMIT 6,10
, and so on.
One thing that would work is to use a for
loop, but it would be very intensive, as I would have to select all of the values from iCloud, and then loop through them to figure out which 5 to select, and I'm anticipating there to be a lot of different posts in the database, so I would like to only load the ones that are needed.
I'm looking for something like this:
var limit: NSLimitDescriptor = NSLimitDescriptor(5, 10)
query.limit = limit
CKContainer.defaultContainer().publicCloudDatabase.addOperation(CKQueryOperation(query: query)
//fetch values and return them