application(_:didFinishLaunchingWithOptions:)' nearly matches optional requirement

前端 未结 2 1844
时光取名叫无心
时光取名叫无心 2021-02-02 09:21

After installing Xcode 8 beta 6, I\'m getting a warning saying:

Instance method \'application(_:didFinishLaunchingWithOptions:)\' nearly matches optional

2条回答
  •  野的像风
    2021-02-02 10:10

    the first parameter passed into the function no longer has an external name. This is really just a minor detail since you don’t call this method directly, and it’s a quick fix to make the compiler happy. You can either manually edit that first parameter name to _, or just let Xcode handle this for you.

    func application(_ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool  
    

    or the New Syntax

    func application(_ application:UIApplication, 
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool // or remove = nil and try
    

    you can get the latest Documentation from apple and sample link in here

提交回复
热议问题