Why ambiguous reference to member 'Subscript'?

410 views Asked by At

This is my Swift 3 code:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    if let userInfo : Foundation.NSDictionary = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? Foundation.NSDictionary {
        self.setNavigationInfoFromPushNotification(userInfo: userInfo)
        navigateFromPushNotification()
    }
    ...
}

It results in a compile-time error that says:

Ambiguous reference to member 'Subscript'

Please can anyone help me with this?

1

There are 1 answers

0
Rob On BEST ANSWER

The method signature has changed. See How to handle launch options in Swift 3 when a notification is tapped? Getting syntax problems.

It is now:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { 
    if let userInfo = launchOptions?[.remoteNotification] as? NSDictionary {
        setNavigationInfoFromPushNotification(userInfo: userInfo)
        navigateFromPushNotification()
    }
    ...
}