UIApplication.sharedApplication()不可用 [英] UIApplication.sharedApplication() is unavailable
问题描述
我刚刚从XCode 6.4升级到Xcode 7 GM,并开始更改代码以与Swift 2兼容.我无法克服以下错误.
I just upgraded from XCode 6.4 to Xcode 7 GM and get started to change the code to be compliant with Swift 2. I could not come over the following errors.
该项目是键盘扩展,代码段来自所包含的应用程序.
The project is a keyboard extension and the snippet is from the containing app.
let s = "https://itunes.apple.com/"
UIApplication.sharedApplication().openURL(NSURL(string : s)!)
错误1:'sharedApplication()'不可用:在适当的地方使用基于视图控制器的解决方案.
Error 1: 'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead.
错误2:"openURL"不可用.
Error 2: 'openURL' is unavailable.
这可能与Xcode和AppDelegate有关,我可能搞砸了我的项目.
This might be something to do with Xcode and AppDelegate, I might have screwed up my project.
推荐答案
包含应用程序的类以某种方式进入了扩展构建阶段中的编译资源列表.我删除了它们,现在可以了.
The classes in containing app somehow went in to the compile resources list in the extension Build Phases. I deleted them, it is ok now.
我没有那样做.显然以某种方式升级到了Xcode 7 GM程序.
I did not do that. Obviously upgrade to Xcode 7 GM process somehow did it.
这篇关于UIApplication.sharedApplication()不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!