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

The WebServiceController protocol

From the course: Swift 5: Protocol-Oriented Programming

Start my 1-month free trial

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…

Contents