December 2018
Intermediate to advanced
414 pages
10h 19m
English
It is very common to share default implementations between your objects, and only implement the difference when needed.
Let's first start by adding a new service to our factory for registering for localization services. Luckily for us, CoreLocation is the same SDK for both iOS and macOS, so we're able to share our implementation between the two platforms, as follows:
protocol UserLocationService { func getUserLocation(done: (CLLocation) -> Void)}struct CommonUserLocationService: UserLocationService { func getUserLocation(done: (CLLocation) -> Void) { // TODO: Implement me }}
Let's now add it to our ServicesFactoryType:
protocol ServicesFactoryType { func getPushService() -> PushNotificationService func getUserLocationService() ...
Read now
Unlock full access