MapKit:如何从MKLocalSearchResponse的返回值中检索公寓号



我在网上彻底搜索,但找不到任何关于这个的讨论:

从 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";
                };
            };
            }"

我能够检索我需要的所有信息,除了公寓号码。它包含在"子前提"部分,我不知道如何检索。

您可能会建议我从我有权访问的"格式化地址行"中检索它,但对于某些结果,该属性是空的,所以我不能依赖它。

我也尝试了"addressDictionary"属性,它有除公寓号码以外的所有必要信息,这对我来说非常不周到。

mapItem.placemark.subThoroughfare. 请注意,它可能为空

相关内容

  • 没有找到相关文章

最新更新