我在网上彻底搜索过,但未找到任何关于此的讨论:
从MapKit搜索返回的MKLocalSearchResponse对象是MKMapItem的集合,其具有搜索结果的信息,例如,城市,州,国家。
单个MKMapItem看起来像这样(从Xcode快速查看对象):
"Name: ADVANCED SOLUTIONS ADDICTION MANAGEMENT CurrentLocation: 0 Place: <GEOPlace: 0x9b2db90> {
address = {
formattedAddressLine = (
\"205 W Crestway Ave\",
\"Unit 200\",
\"Derby, KS 67037-1850\",
\"United States\"
);
structuredAddress = {
administrativeArea = Kansas;
administrativeAreaCode = KS;
country = \"United States\";
countryCode = US;
dependentLocality = (
Derby,
Rockford
);
fullThoroughfare = \"205 W Crestway Ave\";
geoId = (
);
locality = Derby;
postCode = 67037;
postCodeExtension = 1850;
postCodeFull = \"67037-1850\";
subAdministrativeArea = Sedgwick;
subLocality = Rockford;
subPremise = (
{
name = 200;
type = 0;
}
);
subThoroughfare = 205;
thoroughfare = \"W Crestway Ave\";
};
};
}"
除了公寓号码外,我能够检索到我需要的所有信息。它包含在“subPremise”部分中,我不知道如何检索。
您可以建议我从我可以访问的“formattedAddressLines”中检索它,但是对于某些结果,该属性为空,所以我不能依赖它。
我也尝试了“addressDictionary”属性,除了公寓号外,它还有所有必要的信息,这对我来说是非常不合理的。
答案 0 :(得分:1)
mapItem.placemark.subThoroughfare。请注意,它可能是空的