0

Other than the ability to chain different CKQuerys, and the ability to set the limit of retrieve results, why else does one need CKQueryOperation? Are basically those two functionalities it? Because I'm just not sure what the reason for have CKQueryOperation.

shle2821
  • 1,856
  • 1
  • 19
  • 26
  • 2
    *"A CKQuery object manages the criteria to apply when searching for records in a database."* A query is just a description of what to search for. the CKQueryOperation allows you to **perform** the query and receive results. – jtbandes Mar 14 '16 at 04:35

2 Answers2

2

A CKQueryOperation object is a concrete operation that you can use to execute queries against a database. A query operation takes the query parameters you provide and applies those parameters to the specified database and zone, delivering any matching records asynchronously to the blocks that you provide.

NSObject-> NSOperation-> CKOperation-> CKDatabaseOperation-> CKQueryOperation

Queries are restricted to the records in a single zone. For new queries, you specify the zone when you initialize the query operation object. For cursor-based queries, the cursor contains the zone information. To search for records in multiple zones, you must create a separate CKQueryOperation object for each zone you want to search, although you can initialize each of them with the same CKQuery object.

1

The CKconvenience routines are very good for what they are; an introduction to CloudKit, but within a few short noddy programs you soon discover their purpose has some serious limitations.

With CKOperations you make changes such as changes to things like the qualityofservice you want/care about and monitor their execution with far more control then you have with a CKconvenience methods.

It perhaps goes without saying too that having been forced to use CKoperations for record maintenance you might want to structure, use the same techniques in your code across your entire app.

mxcl
  • 26,392
  • 12
  • 99
  • 98
user3069232
  • 8,587
  • 7
  • 46
  • 87