title: CloudKit count records
body: <p>I have a "table" that can potentially have many records, when adding a new record I need to know how many records there already are in current table as I use it in calculation of some values. The closest thing I could find is requesting all entries like this:</p>
  
  <pre><code>var query : CKQuery = CKQuery(recordType: "Stars", predicate: NSPredicate(format: "mass &gt; 0"))
      var request : CKQueryOperation = CKQueryOperation(query: query)
      var starCount = 0
  
      request.queryCompletionBlock = {
          (cursor:CKQueryCursor!, error:NSError!) in
          if error {
              completionHandler(ECOResponse.error(error.description), starCount)
          } else {
              completionHandler(ECOResponse.ok(), starCount)
          }
      }
  
      request.recordFetchedBlock = {
          (record:CKRecord!) in
          starCount += 1
      }
  </code></pre>
  
  <p>I wish queryCompletionBlock gave a count or results array along with CKQueryCursor, but unfortunately it does not.</p>
  
  <p>Is there any other way to calculate number of rows in the table?</p>