0

The operation:

operation.recordMatchedBlock = {recordID, result in switch result { case .success(let record): print("RecordID: \(recordID), record: \(record)") let order = Order() order.recordID = record.recordID order.name = record["name"] order.products = record["products"] newOrders.append(order) orders = newOrders case .failure(let error): print("failed for \(recordID): \(error)") } } 

And here is my model:

class Order:NSObject, Identifiable { var recordID: CKRecord.ID! var name: String! var products: [String]? } 

My record from the public database consists of an array(StringList) - "products".

public database

My problem is that the array(products) is not fetched and/or the values are not properly assigned.

How can I now parse the StringList into my local model properly? Does anyone know the exact syntax?

edit:

If I assign record["products"] to a variable, the value is 'nil'.

And here is the output from the debugger. It seems as if only the key "name" will be found... No trace of "products"

Printing description of success._valueStore: (CKRecordValueStore?) _valueStore = 0x00006000009ade60 { baseNSObject@0 = { isa = CKRecordValueStore } _trackChanges = '\x01' _values = 0x00006000006148e0 1 key/value pair { [0] = { key = "name" value = "John Doe" } } 
1
  • No it's not working, I mean... it builds, but the StringList does not get fetched. Commented Nov 22 at 19:50

1 Answer 1

0

Okay..... I won't delete this post, even though I'm s***** like 5 meters of dirt road....

look at this:

let operation = CKQueryOperation(query: query) operation.desiredKeys = ["name"] operation.resultsLimit = 50 

I forgot to add "products" to the desiredKeys... For everyone: Don't overthink and go through everything again.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.