In my project users cant go to the next view unless they are currently in a specific city. So here is how I check the city of a coordinates
func fetchCountryAndCity(location: CLLocation, completion: @escaping (String, String) -> ()) {
CLGeocoder().reverseGeocodeLocation(location) { placemarks, error in
if let error = error {
print(error)
} else if let country = placemarks?.first?.country,
let city = placemarks?.first?.locality {
completion(country, city)
}
}
}
then when users click on get my current locations I take the coordinates and check:
fetchCountryAndCity(location: location) { country, city in
print("country:", country)
print("city:", city)
if city == "Riyadh" || city == "الرياض" || city == "리야드" || city == "Riyah" {
the problem is I have to check the name of the city in all the languages because the output of the city name depends on the language of the device ( As I found out during testing) and it's just not right. Is there any way other than this to check the name of the city in all languages?