I need to detect in which country and state the device is with Swift 5 and without an Internet connection.
reverseGeocodeLocation:
func getCityInLocation(from
location:CLLocation,completion:@escaping(_city:String?, _ error:Error?) ->()) {
CLGeocoder().reverseGeocodeLocation(location) { placemarks, error in
completion(placemarks ?.first ?.locality, error)
}
}
let location = CLLocation(latitude:19.339248,longitude:-99.191345)
getCityInLocation(from:location) { city, error in
guard let city = city, error == nil else{
return
}
print(city + "Line 705") //
}