Question: I wanna reverse user's location, which contains values of latitude and longitude, into accurate address. But it doesn't work, it returned an empty string after execution.

Also, Xcode suggested me using CNPostalAddress, I have no idea what it is.

Here's the function

```
import Foundation
import CoreLocation
import AddressBook`

    func reverseGeocoder()->String{
        let info:String?
        var geocoder = CLGeocoder()
        var currentUserLocation = CLLocation(latitude: 30, longitude: 122)
        geocoder.reverseGeocodeLocation(currentUserLocation, completionHandler: {
            (placemarks,error) -> Void in
            if placemarks != nil && placemarks?.count > 0{
                let placemark = placemarks![0] as CLPlacemark
                let addressDictionary = placemark.addressDictionary! as NSDictionary

                let str:NSMutableString = ""
                if let address = addressDictionary.objectForKey(kABPersonAddressStreetKey) as? String{
                    str.appendString(address)
                }

                if let state = addressDictionary.objectForKey(kABPersonAddressStateKey) as? String{
                    str.appendString(state)
                }

                if let city = addressDictionary.objectForKey(kABPersonAddressCityKey) as? String{
                    str.appendString(city)
                }

                info = str as String
            }
        }
        )
        return info
}

```

Here are warnings
[![Warnnings](https://i.stack.imgur.com/EFuFy.png)](https://i.stack.imgur.com/EFuFy.png)

appreciate it if you can help me fix it :)

Answer: 
Replace `import AddressBook` with `import Contacts` and also replace 

`addressDictionary.objectForKey(kABPersonAddressStreetKey)` with `addressDictionary.objectForKey(CNPostalAddress.Street)`

`addressDictionary.objectForKey(kABPersonAddressStateKey)` with `addressDictionary.objectForKey(CNPostalAddress.State)`

`addressDictionary.objectForKey(kABPersonAddressCityKey)` with `addressDictionary.objectForKey(CNPostalAddress.City)`

you can get the more information in [Apple Douments](https://developer.apple.com/library/ios/documentation/Contacts/Reference/CNPostalAddress_Class/)

**use Completion**

```
func reverseGeocoder (completion: (info:String) -> Void){

    var geocoder = CLGeocoder()
    var currentUserLocation = CLLocation(latitude: 30, longitude: 122)
    geocoder.reverseGeocodeLocation(currentUserLocation, completionHandler: {
        (placemarks,error) -> Void in
        if placemarks != nil && placemarks?.count > 0{
            let placemark = placemarks![0] as CLPlacemark
            let addressDictionary = placemark.addressDictionary! as NSDictionary

            let str:NSMutableString = ""
            if let address = addressDictionary.objectForKey(kABPersonAddressStreetKey) as? String{
                str.appendString(address)
            }

            if let state = addressDictionary.objectForKey(kABPersonAddressStateKey) as? String{
                str.appendString(state)
            }

            if let city = addressDictionary.objectForKey(kABPersonAddressCityKey) as? String{
                str.appendString(city)
            }
            completion(info: str as String)

        }
    }
    )

```
```
if let coordinates = base.coOrdinates
        {
          if let lat = coordinates.lat {
            let location = CLLocation(latitude: lat, longitude: coordinates.lon!)
            let reverseGeocoder = CLGeocoder()
            reverseGeocoder.reverseGeocodeLocation(location, completionHandler: {place,_ in
              //print(place)
              let myPlacemark = place![0]
              let countryName = myPlacemark.country
              let cityName = myPlacemark.subAdministrativeArea
              let streetName = myPlacemark.subLocality
              NSOperationQueue.mainQueue().addOperationWithBlock {
                self.lastLocationLabel.text = "\(streetName!), \(cityName!), \(countryName!)"
              }
            })
          } else {
            self.lastLocationLabel.text = "Not available"
          }
        }

```

Thsi might help you. This is how i get the location string from coordinates.