Search code examples
swiftxcodeuiapplicationshortcutitem

performActionForShortcutItem in Xcode 8 beta 6


Since I updated to Xcode 8 beta 6 I get a warning for:

application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void)

"Instance method application(_:performActionFor:completionHandler:) nearly matches optional requirement application(_:performActionFor:completionHandler:) of protocol UIApplicationDelegate"

But the method I have in my code is the one that autocomplete fills in. Apparently the method has been changed because my shortcut items don't work anymore but I don't know how to fix it.


Solution

  • Command-click on UIApplicationDelegate, and you can find this:

    (Or see the latests documentation of UIApplicationDelegate.)

    optional public func application(_ application: UIApplication,
        performActionFor shortcutItem: UIApplicationShortcutItem,
        completionHandler: @escaping (Bool) -> Swift.Void)
    

    Try changing your method header to:

    func application(_ application: UIApplication,
        performActionFor shortcutItem: UIApplicationShortcutItem,
        completionHandler: @escaping (Bool) -> Void)