user3069232 user3069232 - 4 years ago 397
Swift Question

CKReference List update

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?

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download