![](/img/trans.png)
[英]iOS Core Data + iCloud error for addPersistentStoreWithType: You don’t have permission to save the file “store” in the folder
[英]I do not have permission to write into iCloud folder
我正在嘗試將文件寫入無處不在的文件夾中,我可以運行查詢並且一切正常,我看到了文件,但是如果我嘗試設置本地文件,我會收到此錯誤:
Error Domain=NSCocoaErrorDomain Code=513 "“video.mp4” couldn’t be moved because you don’t have permission to access “DemoExample”." UserInfo={NSSourceFilePathErrorKey=/var/containers/Bundle/Application/3C3DC6B5-7B22-4B1C-B8AB-187F640F68AB/DemoExample.app/video.mp4, NSUserStringVariant=(
Move
), NSDestinationFilePath=/private/var/mobile/Library/Mobile Documents/iCloud~com~Test~DemoExample/Documents/video.mp4, NSFilePath=/var/containers/Bundle/Application/3C3DC6B5-7B22-4B1C-B8AB-187F640F68AB/DemoExample.app/video.mp4, NSUnderlyingError=0x17405c5c0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
Video.mp4 存在於文件夾中,有什么問題?
這是保存文件的代碼:
try self.fileManager.setUbiquitous(true, itemAt: URL.init(fileURLWithPath:file.path), destinationURL: iCloudUrl)
我用這個:
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.com.Test.DemoExample</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>backup</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>Any</string>
</dict>
請按照以下步驟一一進行。 希望它能解決你的問題......
<key>NSUbiquitousContainers</key> <dict> <key>iCloud.YOUR_BUNDLE_IDENTIFIER</key> <dict> <key>NSUbiquitousContainerIsDocumentScopePublic</key> <true/> <key>NSUbiquitousContainerSupportedFolderLevels</key> <string>Any</string> <key>NSUbiquitousContainerName</key> <string>iCloudDriveDemo</string> </dict> </dict>
這是我的解決方案(@emraz 對我不起作用):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.