From the course: Swift 5: Protocol-Oriented Programming
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Integrating a fallback service
From the course: Swift 5: Protocol-Oriented Programming
Solution: Integrating a fallback service
(upbeat music) - [Narrator] Welcome back! Hopefully, you have managed to come up with an elegant solution. Let me show you one way to approach this problem. Here's the Web Service Controller. I'm going to add an initializer requirement first. The fallback service parameter is a Web Service Controller and it's optional. By making it optional, we allow callers to set it to nil. This indicates that the controller doesn't have a fallback service. Next, I add the fallback service computed property. It's a type Web Service Controller, and it can be nil. So I make it optional. Now and lets make it gettable only. Clients are not supposed to set its value. And now, I am going to switch to the open ethernet controller, the Swift file. I add the fallback service property first. I declare it as a constant to make it immutable. Next comes the initializer. I provide a default nil value for the fallback service parameter. And…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Weather app design2m 32s
-
Defining the UI using SwiftUI4m 20s
-
(Locked)
The WebServiceController protocol5m 13s
-
(Locked)
Working with a third-party API52s
-
(Locked)
Implementing the OpenWeatherMap controller4m 9s
-
(Locked)
Completing the OpenWeatherMap controller2m 42s
-
(Locked)
Introducing the view model3m 8s
-
(Locked)
Presenting weather data2m 39s
-
(Locked)
Challenge: Integrating a fallback service2m 34s
-
(Locked)
Solution: Integrating a fallback service4m 8s
-
-