 
 import Foundation
 import CoreLocation
-import AddressBookUI
+import MapKit
 
 
 public class PGoLocationUtils {

        public var altitude: Double?
        public var distance: Double?
        public var displacement: Double?
    }
    
    public func geocode(latitude: Double, longitude: Double, completionHandler: (location: String?) -> ()) {
        /*
         
         Example func for completionHandler:
         func receivedGeocode(location: String?)
         
         */
        
        let location = CLLocation(latitude: latitude, longitude: longitude)
        CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in
            if placemarks?.count > 0 {
                let addressDictionary = placemarks![0]
                let address = ABCreateStringWithAddressDictionary(addressDictionary.addressDictionary!, false)
                completionHandler(location: address.stringByReplacingOccurrencesOfString("\n", withString: ", "))
            }
        })
    }

        let geocoder = CLGeocoder()
        geocoder.geocodeAddressString(location, completionHandler: {(placeData: [CLPlacemark]?, error: NSError?) -> Void in
            if (placeData?.count > 0) {
                let addressDictionary = placeData![0]
                result = PGoCoordinate(
                    latitude: (placeData![0].location?.coordinate.latitude)!,
                    longitude: (placeData![0].location?.coordinate.longitude)!,
                    altitude: placeData![0].location?.altitude,
                    distance: nil,
                    displacement: nil,
                    address: addressDictionary.addressDictionary!,
                    mapItem: MKMapItem(
                        placemark: MKPlacemark(
                            coordinate: placeData![0].location!.coordinate,
                            addressDictionary: placeData![0].addressDictionary as! [String:AnyObject]?
                        )
                    )
                )
                completionHandler(result)
            } else {
                completionHandler(nil)
            }
        })
    }
