UIApplicationDelegate method - application(_:didFinishLaunchingWithOptions:) showing an error with Swift 4.2 (Xcode 10).
UIApplicationLaunchOptionsKey not found
What is replacement of UIApplicationLaunchOptionsKey
in Swift 4.2?
'UIApplicationLaunchOptionsKey' has been renamed to 'UIApplication.LaunchOptionsKey'. Replace 'UIApplicationLaunchOptionsKey' with 'UIApplication.LaunchOptionsKey'.
Click on error hint, will show you solution:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
}
Xcode would fix-it but UIApplicationLaunchOptionsKey
is replaced by a nested type UIApplication.LaunchOptionsKey
.
It should be UIApplication.LaunchOptionsKey
, Please find following apple documentation
I have tried the below snippet of the code and worked for me.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication: Any]? = nil) -> Bool {
}
Just provide UIApplication in launchOptions. Hopes it will work for you as well. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With