if city name is "La Paz", Open Weather Map will not return JSON Data but it will return it if the user enter a city with one substring e.g. Richmond.
let urlString = "\(weatherURL)&q=\(cityName)"
how can I fix this? Thank you in advance for your help.
Although you question is not fully clear, I assume the issue has to do with the spacing in the textfield. You could try it by using the function addingPercentEncoding(withAllowedCharacters:). This will make the string more URL safe.
Otherwise I'd suggest checking the documentation for Weather Map and see if it requires data differently.