我知道如何获得当前的城市,但我还需要附近的城市名称......
locationManager.startUpdatingLocation() // start updating location
locationManager.startMonitoringSignificantLocationChanges()
currentLocation = self.locationManager.location != nil ? self.locationManager.location : nil
if currentLocation != nil{
geoCoder.reverseGeocodeLocation(currentLocation, completionHandler: {
placemarks, error in
if error == nil && placemarks!.count > 0 {
let placeArray = placemarks as [CLPlacemark]?
// Place details
let placeMark: CLPlacemark! = placeArray?[0]
// City
if let city = placeMark.addressDictionary?["City"] as? NSString {
self.city = city as String
}
}
})
}
我需要一个类似的功能来检索附近的城市名称..有没有办法使用CLLocationManager来做到这一点? 似乎没有API可以做到这一点? https://developer.apple.com/reference/corelocation/cllocationmanager