任何人都可以建议清洁工从 CLPlacemark 创建一个地址字符串。
目前我正在使用这个扩展
extension CLPlacemark {
func makeAddressString() -> String {
var address = ""
if subThoroughfare != nil { address = address + " " + subThoroughfare! }
if thoroughfare != nil { address = address + " " + thoroughfare! }
if locality != nil { address = address + " " + locality! }
if administrativeArea != nil { address = address + " " + administrativeArea! }
if postalCode != nil { address = address + " " + postalCode! }
if country != nil { address = address + " " + country! }
return address
}
}
所有实例变量都是可选的,因此检查 nil,我希望以相同的街道号顺序,到街道等。