title: How to combine data from multiple CloudKit tables?
body: <p>I'm looking for a way to loading data from multiple CloudKit tables into one object.
  Now I'm loading the data from one CloudKit Table (recordType), but how can I combine this data within the function below? I need to add the Activities table connected to the Clients table. So one Client can have multiple Activities.</p>
  
  <p>My Client model:</p>
  
  <pre><code>class Client: NSObject {
    var recordID: CKRecordID!
    var name: String?
    var activities: [Activity]?
    var image: UIImage?
    var email: String?
    var phone: String?
    var rate: Int?
  }
  </code></pre>
  
  <p>My Activity object:</p>
  
  <pre><code>class Activity: NSData {
    var name: String?
    var date: Date?
  }
  </code></pre>
  
  <p>Function for loading only Clients:</p>
  
  <pre><code>private func loadClients() {
      let pred = NSPredicate(value: true)
      let sort = NSSortDescriptor(key: "Name", ascending: true)
      let query = CKQuery(recordType: "Clients", predicate: pred)
      query.sortDescriptors = [sort]
  
      let operation = CKQueryOperation(query: query)
  
      var newClients = [Client]()
  
      operation.recordFetchedBlock = { record in
        let client = Client()
        client.recordID = record.recordID
        client.name = record["Name"] as? String
        client.email = record["Email"] as? String
        client.phone = record["Phone"] as? String
        client.rate = record["Rate"] as? Int
  
        newClients.append(client)
      }
  
      operation.queryCompletionBlock = { [unowned self] (cursor, error) in
        DispatchQueue.main.async {
          if error == nil {
            ViewController.isDirty = false
            self.clients = newClients
  
            if self.clients.count == 0 {
              self.messageLabel.text = "No values in the database"
            } else {
              self.tableView.reloadData()
            }
  
            self.updateView()
          } else {
            self.messageLabel.text = "Error loading data"
            print("ERROR: \(error!.localizedDescription)")
            self.updateView()
          }
        }
      }
  
      CKContainer.default().privateCloudDatabase.add(operation)
   }
  </code></pre>