本文介绍了在Swift中应用openURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了Appdelegate方法OpenURL的问题。

I am having an issue with the Appdelegate method OpenURL.

我已经设置了我的导入UTI和文档类型。但是,当我从邮件附件打开我的应用程序时,应用程序实施时会立即崩溃。

I have setup my Imported UTI's and Document Type. But when opening my app from a mail attachment, the app crashes immediately when I have the method implemented.

折旧的handleOpenURL有效,但不是OpenURL?

The depreciated handleOpenURL works, but not OpenURL?

目前我在实现中没有代码,我只是返回true。

At the moment I have no code in the implementation, and am just returning true.

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String, annotation: AnyObject?) -> Bool {
    return true
}

崩溃说线程1:EXC_BAD_ACCESS(代码-1,地址-0x0)

我真的不想使用弃用的方法。

I don't really want to have to use the deprecated method.

推荐答案

这是Swift编译器自动生成的方法签名与实际签名之间签名不匹配的典型特征。当您尝试将nil从Objective-C传递到Swift显式解包的可选项时,就会发生这种情况。更改注释参数以隐式展开,您应该是gtg。

This is fairly typical of a signature mismatch between the method signatures automatically generated by the Swift compiler and the actual signature. It happens when you try to pass nil from Objective-C into a Swift explicitly unwrapped optional. Change the annotation parameter to be implicitly unwrapped and you should be gtg.

这篇关于在Swift中应用openURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:56