从Xcode 9.3开始无法使用Open in ...打开文件 [英] Unable to open a file using Open in... since Xcode 9.3

查看:114
本文介绍了从Xcode 9.3开始无法使用Open in ...打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode 9.3之前,我没有导入文件的问题,现在尝试在应用程序中使用open打开文件时发生崩溃

Prior to Xcode 9.3 I had no issues importing a file, now when attempting to open a file using open in the app crashes with

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

到达我的

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {

    let urlName = url.lastPathComponent
    print("Gotten a file \(urlName)")
}

因此,在我的应用程序甚至没有获得文件崩溃之前,我都不理解

So before my app even gets the file it crashes which I dont understand

在AppDelegate

In the AppDelegate

我还创建了一个新的空项目并遇到相同的问题

I also created a new empty project and getting the same issue

这些是必需的文档设置

崩溃位置

推荐答案

只是碰巧我碰到了此方法

Just by luck I came across this method

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

      // read in your file 

}

因此,用此方法替换了上面的方法,它就起作用了。

So replaced the method above with this and it worked.

这篇关于从Xcode 9.3开始无法使用Open in ...打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆