I am back with the second episode of my weather app challenge entry, where I start to implement the main UI from a dribbble design, which I showed in the first episode.
I am back with the 4th episode of my weather app challenge entry, in which I clean up the UI and prepare to start implementing the API in episode 5 tomorrow!
A bit late, but hereās episode 5 of my weather app challenge entry, in which I create a model for the JSON API, create an API service and subscribe to the service in a ViewModel.
And episode 6, in which I use downloadable icons and start to show some of the fetched data:
Aaaaaaand back with episode 7!
This episode revolves around refactoring and slight fixes, before tomorrows last major episode, where I will add the ability to add a city using another API route.
I am back with the last major episode: episode 8.
In this episode I create the ability to add cities and fix some other issues.
There will be one last video in the series where I show the final app, i.e. the challenge submission video. Thanks to everyone who watched one of the videos, it really means a lot to me!
Thanks a lot for sharing how you created your app. Ducky is really a handy app. Though I followed your instructions to get the data from the API, I couldnĀ“t get my code running. It feels strange to me that your approach with the URLSession.shared any AnyPublisher is obviously working, but so does my solution with URLsession.shared.dataTask and no Publisher at all. āViele Wege fĆ¼hren nach Romā
Looking forward to watching your final video. Again, nice work and thanks for sharing your work in such detail.
Thank you so much for watching the videos and the nice comment! Yes, youāre right: there are many different ways too implement an API call! I showed the Combine approach, because I believe once you use Combine in a few places you will love it! (At least that happened to me haha)
If you want, I can have a look at why your DataTaskPublisher approach didnāt work
The final video will be out in 1-2 days, depending on when I can find the time to prepare and record it.
Thanks. I already āimprovedā the code (aka, I deleted the code which was not working). In the meantime, IĀ“m not even sure, maybe it was working.
I have:
struct WeatherData (the Ducky code)
public class API with a public func getWeatherData(lat: Double, long: double) ā here I have the URLsession to get the data from openweathermap.org
Now IĀ“m struggling.
I have a view ācurrentTemperatureā. For testing, in this view I have
State private var weatherDataData = [WeatherData]()
a func load() {Api()getWeaterData(lat: 35.4418. long: -94.0377)}
I added in a VStack .onAppear { load() print(weatherDataData)
In the console, I see all the data for the specified lat/long. If I change the values, I get different results. So, this part is working.
But, I canĀ“t specify any variables to get this data so I can show the temperature etc.
I thought to define a variable as an integer (clouds is Int) as
var clouds: int = weatherDataData.first?.daily.first?.clouds ?? 3 which is not working. Also displaying the value as a String in a Text item is also not possible Text(String(weatherDataData.first?.daily.first?.clouds ?? 3)) ā shows ā3ā in the preview
I think I miss just one step to use the data which is retrieved from openweathermap and displayed in the console ā¦ but I canĀ“t figure out how. Not yet.