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.

Implementing the OpenWeatherMap controller

Implementing the OpenWeatherMap controller

From the course: Swift 5: Protocol-Oriented Programming

Start my 1-month free trial

Implementing the OpenWeatherMap controller

- In this video, we integrate the open weather map API and fetch live weather information. We need a new file created in the model group and name it OpenWeatherMapController.Swift. Let's declare the class next. Class OpenweatherMapController. And it should adopt the WebServiceController protocol. Exco generates the steps for us, which is a single method requirement. First, we need to configure the web service endpoint. Let's have a look at the API documentation. Go to API and current weather data. We're going to use the API that accepts unit parameters. So search for Units format. And here's the API call we've been looking for. Let's put it here for now. Now I create a constant called endpoint and assign it the string will just copy it. We need to make a couple of changes to create a URL out of this string. First, let's make it a valid URL by pre pending HTTPS. And I'm going to to replace London with the value of the…

Contents