I have a CKRecord with a CKReferenceList field. I want to add an additional CKReference to the CKReferenceList... I found this reference in stack overflow that gives a stellar example of how to download list from a CKReference List.
var ksubs:[CKRecordID] = []
for kSubscribers in record?.objectForKey("rexReferenced") as! [CKReference] {
ksubs.append(kSubscribers.recordID)
}
But I need to do the inverse, I want to add an additional element to an existing CKreferenceList list. What is the CK equivalent to .append element?
Bon, managed to figure out how to ask the right question and found the answer here.
How to modify CloudKit Reference Lists
Its obvious isn't it.
CKReference *reference = [[CKReference alloc] initWithRecord:connectionRecord action:CKReferenceActionNone];
NSMutableArray *list_a = [record_a[@"connections"] mutableCopy];
if (!list_a) list_a = [NSMutableArray array];
[list_a addObject:reference];
record_a[@"connections"] = list_a;