I would like to extend UIApplicationDelegate
protocol and provide a default implementation for application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
method. However, default implementation I have provided does not get called.
Is it possible at all to extend UIApplicationDelegate
protocol (with relation to UIApplication
being a singleton, or protocol method being an optional), or am i doing something wrong?
thanks
AppDelegate.swift:
import UIKit
extension UIApplicationDelegate{
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
print("does not print anything on launch.")
return true
}
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
}
turns out you can't provide default implementations for Objective-C protocols via extensions. See below link for detailed list of limitations on protocol extensions.
What we CAN'T do: Provide default implementations for Objective-C protocols.