Xcode 9.2 UIDocumentBrowserViewController:无法从bookmarkableString

时间:2017-12-05 17:03:50

标签: ios xcode core-data uidocument

更新: Xcode 9.3修复了它。

UIDocumentBrowserViewController

中创建UIDocument文件时

enter image description here

  

[默认] [错误]无法解析书签。错误:错误域= 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)
    }
}

enter image description here

0 个答案:

没有答案