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
From the course: Swift 5: Protocol-Oriented Programming
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…
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
-
-