我有一个简单的 UIDocument 子类,具有覆盖load
和contents
功能。
在 iOS 13 更新之前,json 文档保存在 url“ /private/var/mobile/Library/Mobile Documents/iCloud~appbundle/Documents/EFB7FCBA96684AC0B101E3CD829E6996.json ”中
在当前 iOS 版本 13.2.2(更新后)中,此文档无法打开:
let cloudDocument: ICloudDocument = ICloudDocument(fileURL: url)
cloudDocument.open { (openSuccess) in
if openSuccess {
success()
} else {
// in my case openSuccess is false
failure()
}
}
调试信息。
handleError
在 iCloudDocument 中覆盖后
override func handleError(_ error: Error, userInteractionPermitted: Bool) {
print("userInteractionPermitted - \(userInteractionPermitted)")
print(error)
}
在控制台中:
userInteractionPermitted - true
Error Domain=NSCocoaErrorDomain Code=256 "The file “EFB7FCBA96684AC0B101E3CD829E6996” couldn’t be opened." UserInfo={NSURL=file:///private/var/mobile/Library/Mobile%20Documents/iCloud~appbundle/Documents/EFB7FCBA96684AC0B101E3CD829E6996.json}
如果我cloudDocument.read
在 ICloudDocument 中使用方法,它可以很好地从文件接收数据,但open
会引发错误。
DocumentStatecloudDocument.documentState
的文档已关闭。
文件选项:
> print(FileManager.default.isWritableFile(atPath: url.path))
true
> print(FileManager.default.isReadableFile(atPath: url.path))
true
URLResourceKeys:
URLResourceKey.ubiquitousItemIsUploadingKey - true
URLResourceKey.ubiquitousItemIsUploadedKey - false
URLResourceKey.ubiquitousItemUploadingErrorKey - nil
URLResourceKey.ubiquitousItemHasUnresolvedConflictsKey - false
URLResourceKey.isUbiquitousItemKey - true
URLResourceKey.ubiquitousItemDownloadingStatusKey - "NSURLUbiquitousItemDownloadingStatusCurrent"
我发现一个关于这个问题的链接没有答案 https://forums.developer.apple.com/thread/126889
有任何想法吗?