Please help me build weather app I'm stuck

I really could not go any further. I want to make a weather app that can take coordinates automatically,

Please someone help.

I am linking the project that I’ve done so far here

I am using the open weather app API.

I’ve watched many YouTube videos but they are completely different than the way I learnt from Chris.

Please share the code so that I can also go forward. Please.

Hi riskjockeyy,

I changed the following in your app.

Constant.swift
=> prepend your url with “https://”
"https://api.openweathermap.org/data/2.5/weather?appid=224921567c7100348203b3a4aca3134c"

WeatherModel.swift
=> in the getCoordinates function change

urlComponent?.queryItems = [
    URLQueryItem(name: "latitude", value: String(location.coordinate.latitude)),
    URLQueryItem(name: "longitude", value: String(location.coordinate.longitude)),
]

to:

urlComponent?.queryItems = [
    URLQueryItem(name: "lat", value: String(location.coordinate.latitude)),
    URLQueryItem(name: "lon", value: String(location.coordinate.longitude)),
    URLQueryItem(name: "appid", value: Constant.apiKey)
]

Hope this helps for you.

Greetings,
Johannes

Thank you so much could you please help me map the coding keys

here is the json response

{
“coord”: {
“lon”: -122.08,
“lat”: 37.39
},
“weather”: [
{
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
}
],
“base”: “stations”,
“main”: {
“temp”: 282.55,
“feels_like”: 281.86,
“temp_min”: 280.37,
“temp_max”: 284.26,
“pressure”: 1023,
“humidity”: 100
},
“visibility”: 16093,
“wind”: {
“speed”: 1.5,
“deg”: 350
},
“clouds”: {
“all”: 1
},
“dt”: 1560350645,
“sys”: {
“type”: 1,
“id”: 5122,
“message”: 0.0139,
“country”: “US”,
“sunrise”: 1560343627,
“sunset”: 1560396563
},
“timezone”: -25200,
“id”: 420006353,
“name”: “Mountain View”,
“cod”: 200
}

I think I made a mistake while mapping the keys and that is also giving me problems .

Thanks in advance

Hey,

Your model looks fine. I’ve printed some of the results in the view as an example.

Please share the code I’ll be greatful

OMG I can’t believe this. May god bless you. You have no idea how happy I am. I was totally confuse about what I was doing . But thank god I was on a right track.

I can’t thank you enough. I was completely demotivated. Thank you thank you thank you. You are an angle . Thanks again

You’re welcome. I’m glad I was able to help you.