I have an API URL where I input a street name through the variable self.origin.input
. This works all well and fine untill I input a street name with a non english character for example Å, Ä and Ö which are common characters here in Sweden. If I do this I get the error message:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Does anyone know how to fix this?
Here is the part of my code where the error occurs:
let locationUrl = URL(string: "https://nominatim.openstreetmap.org/search?country=Sweden&city=Stockholm&street=\(self.origin.input)&format=json")
URLSession.shared.dataTask(with: locationUrl!) {data, response, error in
if let data = data {
// My logic here
}
}