【发布时间】:2019-07-15 20:51:18
【问题描述】:
我需要使用 Swift 5 检测设备在哪个国家和州,并且没有 Internet 连接。
reverseGeocodeLocation:
func getCityInLocation(from
location:CLLocation,completion:@escaping(_city:String?, _ error:Error?) ->()) {
CLGeocoder().reverseGeocodeLocation(location) { placemarks, error in
completion(placemarks ?.first ?.locality, error)
}
}
let location = CLLocation(latitude:19.339248,longitude:-99.191345)
getCityInLocation(from:location) { city, error in
guard let city = city, error == nil else{
return
}
print(city + "????Line 705") //
}
【问题讨论】:
标签: ios swift core-location reverse-geocoding