I want get my Current City name in my iPhone App.
I\'m currently getting the latitude and longitude using CLLocationManager and than i am passing my coordinates into
Please check the bellow function
func getDataCity(tmpLat:Double,tmpLong:Double) {
let tmpCLGeocoder = CLGeocoder.init()
if tmpLat > 0 , tmpLong > 0
{
let tmpDataLoc = CLLocation.init(latitude: tmpLat, longitude: tmpLong)
tmpCLGeocoder.reverseGeocodeLocation(tmpDataLoc, completionHandler: {(placemarks,error) in
guard let tmpPlacemarks = placemarks else{
return
}
let placeMark = tmpPlacemarks[0] as CLPlacemark
guard let strLocality = placeMark.locality else{
return
}
// strLocality is your city
guard let strSubLocality = placeMark.subLocality else{
return
}
// strSubLocality is your are of city
})
}
}