使用未声明的类型'UIApplicationLaunchOptionsKey'

时间:2016-10-18 05:45:31

标签: ios swift2

最近将一个项目转换为Swift 2.2并运行以前不存在的问题。我试过寻找一种解决方法,但没有发现任何类似的帖子。

使用未声明的类型'UIApplicationLaunchOptionsKey'。

我无法分辨AppDelegate.swift中此代码的错误:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    //UIToolbar.appearance().tintColor = UIColor.clearColor()

    return true
}

2 个答案:

答案 0 :(得分:3)

尝试将方法签名更改为

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    return true
}

签名在swift 3

中修改为func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool

答案 1 :(得分:0)

在Swift 3中,方法更改为:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true

}