gpt4 book ai didi

ios - 不允许创建操作

转载 作者:行者123 更新时间:2023-11-28 07:13:16 24 4
gpt4 key购买 nike

我正在尝试在我的 iOS 应用程序中使用 CloudKit,但是当我尝试为 User 记录类型创建新记录时(记录类型名为 Users),我收到此错误:

<CKError 0x7fb80947ffb0: "Permission Failure" (10/2007);
server message = "CREATE operation not permitted";
uuid = 8C4C7B60-E3F4-42FC-9551-D3A76A6FF9D6;
container ID = "iCloud.com.jojodmo.Blix">

为了创建新记录,我在 viewDidLoad() 中使用了这段代码:

UserCKManager.create(
CloudKitUser(
email: "email@website.com", password: "password", salt: "1AF4E759B20FEC32",
username: "jojodmo", posts: [], biography: "This is my bio",
firstName: "John", lastName: "Doe", flags: [],
profilePicture: UIImage(), downVotesGiven: 1, downVotesRecieved: 2,
upVotesGiven: 3, upVotesRecieved: 4, pictureProvided: false), callback: nil)

创建一个新的CloudKitUser:

init(email: String, password: String, salt: String, username: String, posts: [String], biography: String, firstName: String, lastName: String, flags: [String], profilePicture: UIImage, downVotesGiven: Int, downVotesRecieved: Int, upVotesGiven: Int, upVotesRecieved: Int, pictureProvided: Bool){ 
self.ready = false
record = CKRecord(recordType: "Users")
self.email = email
self.password = password
self.salt = salt
self.username = username
self.posts = posts
self.biography = biography
self.firstName = firstName
self.lastName = lastName
self.flags = flags
self.profilePicture = profilePicture
self.downVotesGiven = downVotesGiven
self.downVotesRecieved = downVotesRecieved
self.upVotesGiven = upVotesGiven
self.upVotesRecieved = upVotesRecieved
self.pictureProvided = pictureProvided
self.ready = true
}

然后尝试用它创建一条记录:

class func create(user: User, callback: ((success: Bool, user: User?) -> ())?){
let ckUser = CloudKitUser(user: user)
//I've also tried using CKContainer.defaultContainer().privateCloudDatabase, and I get the same error
CKContainer.defaultContainer().publicCloudDatabase.saveRecord(ckUser.record){(record, error) in
if(error != nil){
println("An error occurred: \(error)")
callback?(success: false, user: nil)
}
else{
println("Record saved successfully")
callback?(success: true, user: ckUser)
}
}
}

我知道连接到数据库不是问题,因为我已经收到一条错误消息,指出不存在具有我提供的 ID 的容器,我已修复。

我正在尝试在 iOS 模拟器上运行它(我在上面登录了 iCloud)

最佳答案

Users 是一种特殊的 recordType,它已经存在于 CloudKit 中。您不应该自己创建记录。将为使用您的应用程序的新用户自动创建记录。您也不能创建订阅和查询用户记录类型。只能通过ID直接查询Users记录。您可以在用户记录类型中存储额外的数据,但我认为在您的情况下,如果您将记录类型命名为其他内容会更好。

关于ios - 不允许创建操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27560627/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com