title: CKRecord get value for key
body: <p>I'm trying to get values for a user based on their username. I am able to get the correct user using:</p>
  
  <pre><code>class func getByUsername(username: String, callback: (records: [CKRecord]) -&gt; ()){
      getSummary(NSPredicate(format: "Username == %@", username)){(records: [CKRecord]) -&gt; Void in
          callback(records: records)
      }
  }
  
  class func getSummary(predicate: NSPredicate, callback: (records: [CKRecord]) -&gt; ()){
      let query = CKQuery(recordType: "UserInfo", predicate: predicate)
      let queryOperation = CKQueryOperation(query: query)
      queryOperation.desiredKeys = ["ID"]
  
      var records = [CKRecord]()
      queryOperation.recordFetchedBlock = {record in records.append(record)}
      queryOperation.queryCompletionBlock = {_ in callback(records: records)}
  
      CKContainer.defaultContainer().publicCloudDatabase.addOperation(queryOperation)
  }
  </code></pre>
  
  <p>and I am then able to get the correct record by calling:</p>
  
  <pre><code>getByUsername("Username"){(records: [CKRecord]) -&gt; Void in
    var record: CKRecord = records[0]
  }
  </code></pre>
  
  <p>and I can also get the correct ID by using</p>
  
  <pre><code>var id: String = record.recordID.recordName
  </code></pre>
  
  <p>So I know for a fact that I am fetching the correct record, but, when I try to get values from the record, such as the user's email, <code>nil</code> is returned:</p>
  
  <pre><code>var email: String = record.objectForKey("Email") as String
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>record.valueForKey("Email")
  record.valueForKeyPath("Email")
  </code></pre>
  
  <p>When I print <code>record.allKeys()</code>, I get an empty array, <code>[]</code>, and when I print <code>record.allTokens()</code>, I get a return of <code>nil</code></p>
  
  <p>Am I not fetching a value from the record correctly, or do I have to query the database for every single value that I would like to get using the record ID? Based on what <a href="https://developer.apple.com/library/prerelease/ios/documentation/CloudKit/Reference/CKRecord_class/index.html" rel="nofollow">the documentation</a> says:</p>
  
  <blockquote>
    <p>A CKRecord object is a dictionary of key-value pairs that you use to fetch and save the data of your app. </p>
  </blockquote>
  
  <p>I would assume that I do not have to query the database for every value that I would like to get, and that the values are automatically inserted into the <code>CKRecord</code> upon getting it from <code>iCloud</code></p>