更新: Xcode 9.3修复了它。
在UIDocumentBrowserViewController
[默认] [错误]无法解析书签。错误:错误域= NSFileProviderInternalErrorDomain代码= 1“不允许读者访问该URL。” UserInfo = {NSLocalizedDescription =不允许读者访问该URL。}
[DocumentManager]无法从bookmarkableString创建URL(错误域= NSFileProviderInternalErrorDomain Code = 1“不允许读者访问该URL。”UserInfo = {NSLocalizedDescription =不允许读者访问该URL。})
代码在Xcode 9.1中运行良好,但在Xcode 9.2中失败。与wwdc 2017几乎相同的代码。
func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void) {
let newDocumentURL: URL? = R.file.templateDocument()
// Set the URL for the new document here. Optionally, you can present a template chooser before calling the importHandler.
// Make sure the importHandler is always called, even if the user cancels the creation request.
if newDocumentURL != nil {
importHandler(newDocumentURL, .copy)
} else {
importHandler(nil, .none)
}
}