我正在尝试将文件写入 ubiquitous 文件夹,我可以运行查询并且一切正常,我看到了文件,但是如果我尝试设置本地文件,我会收到此错误:
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>