gpt4 book ai didi

ios - 如何将资源保存到 CloudKit sharedCloudDatabase?

转载 作者:行者123 更新时间:2023-11-28 08:17:09 28 4
gpt4 key购买 nike

我收到以下错误:

An error occurred in CKError 0x6180000575b0: "Invalid Arguments" (12/2006); server message = "Cannot convert userId to dsId due to an invalid userId. Please check the format of the userId."; uuid = E843A411-D192-4435-BAC1-F52EDCA87990; container ID = "iCloud.com.example.myApp"

而我的代码如下:

func uploadAsset(recordType: String, fileURL: URL) {
let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!

let asset = CKAsset(fileURL: fileURL)

let recordZoneID = CKRecordZoneID(zoneName: "Notes", ownerName: "_abcdeg")
let record = CKRecord(recordType: recordType, zoneID: recordZoneID)
record.setObject(asset, forKey: "file")

CKContainer.default().sharedCloudDatabase.save(record) { savedRecord, error in
if let saveError = error {
print("An error occurred in \(saveError)")
} else {
print(savedRecord)
}
}

感谢任何帮助。提前致谢。

最佳答案

我是一个完整的 swift ios 新手,遇到了同样的问题。这是由于在区域 ID 中设置了错误的所有者名称引起的。请改用此方法:

让 recordZoneID = CKRecordZone(zoneName: "Notes").zoneID

然后所有者将被设置为当前用户。

关于ios - 如何将资源保存到 CloudKit sharedCloudDatabase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42271775/

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