How to modify CloudKit Reference Lists

我怕爱的太早我们不能终老 提交于 2019-12-09 23:53:15

问题


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.


回答1:


Turns out that one has to use CKModifyRecordsOperation to modify existing CKRecords.



来源:https://stackoverflow.com/questions/29988207/how-to-modify-cloudkit-reference-lists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!