From the course: Swift 5: Protocol-Oriented Programming
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
The WebServiceController protocol
From the course: Swift 5: Protocol-Oriented Programming
The WebServiceController protocol
- [Instructor] We've implemented the basic UI for our app. The next logical step is to start feeding it with data. So let's continue with the model layer. We'll be relying on web services to retrieve accurate weather information. There are various weather web services available, both free and paid. We're going to use two web services provided by openweathermap.org and weatherstack.com. Both services return their response in JSON format, but the payload structure and contents are different. Although the APIs are incompatible, we need to integrate them seamlessly into our application. We start by creating the service protocol that defines the common method requirements and the expected results and errors. Then we'll define dedicated controllers for each web service. These controllers need to expose the API defined by the service protocol. Thus we won't have to deal with different, incompatible interfaces in our application…
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
-
The WebServiceController protocol5m 13s
-
Working with a third-party API52s
-
Implementing the OpenWeatherMap controller4m 9s
-
Completing the OpenWeatherMap controller2m 42s
-
Introducing the view model3m 8s
-
Presenting weather data2m 39s
-
Challenge: Integrating a fallback service2m 34s
-
Solution: Integrating a fallback service4m 8s
-
-