Reverse Geocode Location in Swift [closed] Reverse Geocode Location in Swift [closed] ios ios

Reverse Geocode Location in Swift [closed]


you never reverse geocode the location but you pass in manager.location.

see:CLGeocoder().reverseGeocodeLocation(manager.location, ...

I assume that was a copy&paste mistake and that this is the issue - the code itself looks good - almost ;)

working code

    var longitude :CLLocationDegrees = -122.0312186    var latitude :CLLocationDegrees = 37.33233141        var location = CLLocation(latitude: latitude, longitude: longitude) //changed!!!    println(location)        CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in        println(location)        guard error == nil else {            println("Reverse geocoder failed with error" + error.localizedDescription)            return        }        guard placemarks.count > 0 else {            println("Problem with the data received from geocoder")            return        }        let pm = placemarks[0] as! CLPlacemark        println(pm.locality)    })