我正在尝试将文件写入无处不在的文件夹,我可以运行查询,一切正常,我看到文件,但如果我尝试设置本地文件,我会收到此错误:
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>
答案 0 :(得分:0)
请逐一按照以下步骤操作。希望它能解决你的问题......
<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>
答案 1 :(得分:0)
这是我的解决方案(@emraz 对我不起作用):