PluggableApplicationDelegate
PluggableApplicationDelegate copied to clipboard
Use Swift 4 lazy property override capability
Now you can do this:
open class PluggableApplicationDelegate: UIResponder, UIApplicationDelegate {
public var window: UIWindow?
private(set) lazy var services: [ApplicationService] = {
return [ /* Populated from sub-class */ ]
}()
}
@UIApplicationMain
class AppDelegate: PluggableApplicationDelegate {
override lazy var services: [ApplicationService] = {
return [
LoggerApplicationService(),
DataApplicationService(),
AnalyticsApplicationService(),
ThemeApplicationService()
]
}()
}
I think it's not necessary to apply here lazy loading. Since there is at least 1 service.
Instead of an empty array, use fatalError() when the services not overwritten.