Swift 中的应用程序 openURL [英] application openURL in Swift

查看:48
本文介绍了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
}

崩溃说Thread 1: EXC_BAD_ACCESS (code-1, address-0x0)

我真的不想使用已弃用的方法.

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

推荐答案

这是 Swift 编译器自动生成的方法签名与实际签名之间相当典型的签名不匹配.当您尝试将 Objective-C 中的 nil 传递给 Swift 显式解包的可选项时,就会发生这种情况.将 annotation 参数更改为隐式解包,您应该是 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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