title: iCloud error reading records with asset or asset lists
body: <p>Running Xcode 7.1.1 under El Capitan on an iPad with iOS 9.2.</p>
  
  <p>Running this code against a very simple database ... with a database containing a record type defined as a string, a reference + an asset field. </p>
  
  <pre><code>-(void)slideLoader:(CKRecordID*)slideReference {
  privateDB = [[CKContainer defaultContainer] privateCloudDatabase];
  
  NSPredicate* predicate = [NSPredicate predicateWithFormat:@"presentationReference == %@", slideReference];
  CKQuery *query = [[CKQuery alloc] initWithRecordType:@"Slides" predicate:predicate];
  
  [privateDB performQuery:query inZoneWithID:nil completionHandler:^(NSArray *results, NSError *error){
      if(error) {
          NSLog(@"Error: %@", error.localizedDescription);
      }
      if(results) {
        for(CKRecord *record in results) {
              NSString *blah = [NSString stringWithFormat:@"%@",record[@"Order"]];
              CKRecordID *blahR = record.recordID;
              [pickerNames addObject:blah];
              [slidesReferenceID addObject:blahR];
              }
          }
     }];
  }
  </code></pre>
  
  <p>It crashes with this error message [below] ... and wait it doesn't even get to the for loop; it crashed before that line. Now if I go into the iCloud dashboard and delete the asset field, it works perfectly... so what am I missing here? </p>
  
  <pre><code>&lt;NSXPCConnection: 0x1557293e0&gt; connection to service named com.apple.cloudd:    Warning: Exception caught during decoding of received message, dropping incoming message.
  Exception: Exception while decoding argument 0 (#2 of invocation):
  &lt;NSInvocation: 0x1555672e0&gt;
  return value: {v} void
  target: {@} 0x0
  selector: {:} handleOperationCompletion:forOperationWithID:
  argument 2: {@} 0x0
  argument 3: {@} 0x0
  
  Exception: value for key 'NS.keys' was of unexpected class 'CKRecordID'. Allowed classes are '{(
  NSURL,
  NSString,
  NSDate,
  NSData,
  NSNumber,
  NSDictionary,
  NSError,
  NSArray
  )}'.
  </code></pre>
  
  <p>Tried a slightly more simplistic version with Swift 2.0; same error. Here is that code, included as a mixed objective C/Swift 2.0 build. The Swift file is called "iCloudMethods.swift".</p>
  
  <pre><code>import Foundation
  import CloudKit
  
  @objc class iCloudMethods: NSObject {
  
  func slideLoader(slideReference: CKRecordID)  {
  
  let container = CKContainer.defaultContainer()
  let privateDB = container.privateCloudDatabase
  
  let predicate = NSPredicate(format: "presentationReference == %@", slideReference)
  let query = CKQuery(recordType: "Slides", predicate: predicate)
  
  privateDB.performQuery(query, inZoneWithID: nil) { (results, error) -&gt; Void in
          if error != nil {
              print(error)
          }
          if((results) != nil) {
              for result in results! {
                  print(result["Order"])
              }
          }
      }
  }
  }
  </code></pre>
  
  <p>Called with the statements...</p>
  
  <pre><code>#import "projectName-Swift.h"
  
  iCloudMethods *iCloudMethod = [[iCloudMethods alloc] init];
  [iCloudMethod slideLoader:presentationReferenceID[row]];
  </code></pre>
  
  <p>Sadly still crashes, same error message when I add assets to the dashboard, works perfectly if I leave them empty? To be sure the record definition looks like this...</p>
  
  <p><a href="https://i.stack.imgur.com/bsrRk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bsrRk.png" alt="enter image description here"></a></p>
  
  <p>Even tried to do this with an basic query operation, still fails.</p>
  
  <pre><code>func slideLoaderV2(slideReference: CKRecordID)  {
      let container = CKContainer.defaultContainer()
      let privateDB = container.privateCloudDatabase
  
      let predicate = NSPredicate(format: "presentationReference == %@", slideReference)
      let query = CKQuery(recordType: "Slides", predicate: predicate)
      let operation = CKQueryOperation(query: query)
  
      operation.recordFetchedBlock = { (record) in
                     print(record["Order"])
      }
  
      operation.queryCompletionBlock = { [unowned self] (cursor, error) in
          dispatch_async(dispatch_get_main_queue()) {
              if error == nil {
                  print("ok")
              } else {
                  print(error!.localizedDescription)
              }
          }
      }
       _ = privateDB.addOperation(operation)
  }
  </code></pre>