iosswiftcloudcloudkitckquery

Reason for existence of CKQueryOperation when CKQuery exists


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.


Solution

  • 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.