Question

I searched thoroughly online but couldn't find any discussion about this:

The MKLocalSearchResponse object returned from a MapKit search is a collection of MKMapItem, which has the information of search results, e.g. City, state, country.

A single MKMapItem looks like this(from Xcode quick look of the object):

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

I was able to retrieve all the information I needed, except the Apartment number. It's contained in the "subPremise" part, which I don't know how to retrieve.

You may suggest me to retrieve it from the "formattedAddressLines", which I have access to, but for some results, that property is empty, so I cannot rely on it.

I've also tried the "addressDictionary" property, it has all the necessary information except apartment number, which is very unthoughtful to me.

Was it helpful?

Solution

mapItem.placemark.subThoroughfare. Note that it may be empty

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top