如何修改CloudKit参考列表 [英] How to modify CloudKit Reference Lists

查看:75
本文介绍了如何修改CloudKit参考列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在仪表板中毫无问题地修改CKRecord的引用列表属性,但是如何以编程方式对其进行修改?

I can modify the Reference List attribute of my CKRecord in the dashboard without problems, but how can I modify it programmatically?

我目前尝试将其修改为NSArray。 。它不会给我带来任何类型的错误,但是即使数组内容很好,也不会设置该属性。

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
                    }
                }];

感谢任何想法或建议。

推荐答案

原来,必须使用 CKModifyRecordsOperation 来修改现有的CKRecord。

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

这篇关于如何修改CloudKit参考列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆