December 2018
Intermediate to advanced
414 pages
10h 19m
English
Through inheritance, we can make our ServicesFactory into a ServicesFactoryType and then ensure that, instead of conforming to ServicesFactoryType, both iOSServicesFactory and macOSServicesFactory inherit from ServicesFactory.
All common services can then be implemented on ServicesFactory, instead of repeatedly on each ServicesFactoryType implementation, as follows:
class ServicesFactory: ServicesFactoryType { static let shared: ServicesFactoryType = { /* same implementation */ }() internal init() {} func getPushService() -> PushNotificationService { fatalError("abstract method, implement in subclasses") } func getUserLocationService() -> UserLocationService { return CommonUserLocationService() }}
Now, ServicesFactory is a ...
Read now
Unlock full access