I can modify the Reference List attribute of my CKRecord in the dashboard without problems, but how can I modify it programmatically?
I currently try modifying it as a NSArray. It does not give me any sort of error but even though the array content is fine, the attribute does not get set.
Also the documentation on reference lists is either well-hidden or non-existent.
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;
[publicDatabase saveRecord:record_a completionHandler:^(CKRecord *artworkRecord, NSError *error){
if (!error) {
// Insert successfully saved record code
}
else {
// Insert error handling
}
}];
I am thankful for any ideas or suggestions.
Turns out that one has to use CKModifyRecordsOperation
to modify existing CKRecords.
来源:https://stackoverflow.com/questions/29988207/how-to-modify-cloudkit-reference-lists