I'm using swift MapKit MKLocalSearch. It returns an array of MKLocalSearchCompletion. However, MKLocalSearchCompletion only exposes title and subtitle fields. I want to extract the City and State from the address, but simply deconstructing the subtitle doesn't work since it has an unreliable format (sometimes the city is the 2nd or 3rd component, if you split it by ",", and sometimes it is not there - only a postal code. I used AppCode's debugger and found that the information that I want - neatly strcutured - is actually potentially available but it is buried deep down in MKLocalSearchCompletion, and it isn't accessible (it is private)... The type is GEOStructuredAddress and it has all the fields returned by MapKit. Here is how it is buried in MKLocalSearchCompletion (where self = MKLocalSearchCompletion)
(((((self.addressResults[0]._mapItem as! MKMapItem *)._geoMapItem as! _GEOPlaceDataItem *)._place as! GEOPlace *)._address as! GEOAddress *)._structuredAddress as! GEOStructuredAddress *)._administrativeArea
What can I do to get this info? Is there a diffrent way to use MapKit to make a query which will give me more control of the response?
I already saw https://stackoverflow.com/a/41718320/5683904 but I'm not sure how to use it with MKLocalSearchCompleterDelegate. (I assume that I'm going to need to use MKLocalSearch and create my own "completer" - is this the only way?)