Last active
March 18, 2018 10:51
-
-
Save Ravi61/66ffa7ce560bf36fcddc3371735b01e8 to your computer and use it in GitHub Desktop.
Code for ResponsibilityDelegator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
class ResponsibilityDelegator: NSObject { | |
var workers: [UIApplicationDelegate] | |
init(workers: [UIApplicationDelegate]) { | |
self.workers = workers | |
} | |
} | |
extension ResponsibilityDelegator: UIApplicationDelegate { | |
@discardableResult | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool { | |
workers.forEach { worker in | |
_ = worker.application?(application, didFinishLaunchingWithOptions: launchOptions) | |
} | |
return true | |
} | |
func applicationDidBecomeActive(_ application: UIApplication) { | |
workers.forEach { worker in | |
worker.applicationDidBecomeActive?(application) | |
} | |
} | |
func applicationWillEnterForeground(_ application: UIApplication) { | |
workers.forEach { worker in | |
worker.applicationWillEnterForeground?(application) | |
} | |
} | |
func applicationWillResignActive(_ application: UIApplication) { | |
workers.forEach { worker in | |
worker.applicationWillResignActive?(application) | |
} | |
} | |
func applicationDidEnterBackground(_ application: UIApplication) { | |
workers.forEach { worker in | |
worker.applicationDidEnterBackground?(application) | |
} | |
} | |
func applicationWillTerminate(_ application: UIApplication) { | |
workers.forEach { worker in | |
worker.applicationWillTerminate?(application) | |
} | |
} | |
func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) { | |
workers.forEach { worker in | |
worker.application?(application, didRegister: notificationSettings) | |
} | |
} | |
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
workers.forEach { worker in | |
worker.application?(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) | |
} | |
} | |
func application(_ application: UIApplication, didReceive notification: UILocalNotification) { | |
workers.forEach { worker in | |
worker.application?(application, didReceive: notification) | |
} | |
} | |
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { | |
workers.forEach { worker in | |
worker.application?(application, didReceiveRemoteNotification: userInfo) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment