Cloudkit:“错误保存记录,不允许写操作。 [英] Cloudkit: " error saving record WRITE operation not permitted"

查看:84
本文介绍了Cloudkit:“错误保存记录,不允许写操作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试保存记录CloudKit,但是我从cloudkit中收到以下错误:

I'm trying to save a record CloudKit but I'm getting the following error from cloudkit:

error saving record este es error: Error saving record <CKRecordID: 0x7fef15b5d2a0; 2:(_defaultZone:__defaultOwner__)> to server: WRITE operation not permitted

这是我要保存记录的方式:

Here is how I'm trying to save the record:

[publicDatabase saveRecord:recordContent completionHandler:^(CKRecord *record, NSError *error){

if (!error)
{
    NSLog(@"saved!!!");

}
else
{
    if ([[error.userInfo valueForKey:@"ErrorDescription"] isEqualToString:@"record to insert already exists"])
    {
        NSLog(@"record already exist %@",[error.userInfo valueForKey:@"ErrorDescription"]);

    }

    NSLog(@"error saving record : %@",error.localizedDescription);
}
}];

但是我之前没有检查过cloudkit是否可用:

But before had I check if cloudkit is available:

[myContainer accountStatusWithCompletionHandler:^(CKAccountStatus accountStatus, NSError *error)
     {
         NSLog(@" no error but status %ld",accountStatus);

         if (((accountStatus == 3) || (accountStatus == 2)) && (!error))
         {
             NSLog(@" no error but status %ld",accountStatus);


             //            typedef NS_ENUM(NSInteger, CKAccountStatus) {
             //                /* An error occurred when getting the account status, consult the corresponding NSError */
             //                CKAccountStatusCouldNotDetermine                   = 0,
             //                /* The iCloud account credentials are available for this application */
             //                CKAccountStatusAvailable                           = 1,
             //                /* Parental Controls / Device Management has denied access to iCloud account credentials */
             //                CKAccountStatusRestricted                          = 2,
             //                /* No iCloud account is logged in on this device */
             //                CKAccountStatusNoAccount                           = 3,
             //
             //        }
         }


         if (error)
         {
             NSLog(@" accountStatus error %@",error);

         }
     } ];

我在哪里获得状态1,表示CKAccountStatusAvailable。

Where I'm getting status 1, meaning CKAccountStatusAvailable.

你们中的任何人都知道为什么这种情况一直有效,直到最后一个记录为止,或者您知道有人在解决此问题吗?

Any of you knows why this is happening it has been working fine until the last record or any of you knows a work around this?

非常感谢您的帮助。

推荐答案

您需要设置权限以允许用户写入(或删除)其他人创建的记录。您可以在开发环境中的架构,记录类型下选择特定的记录,然后在右侧的下拉菜单中选择安全性。授予已验证角色读写权限。然后部署到生产环境。

You need to set permission to allow a user to write (or delete) a record created by someone else. You do that in the Development Environment, under Schema, Record Types, select the specific record, then over on the right there is a drop down menu labelled Security. Grant to the Role ' Authenticated' the right to Read and Write. Then deploy to Production.

这篇关于Cloudkit:“错误保存记录,不允许写操作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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