Question

I want access to the data in a MKMapItem object. After searching for information, I am asking the community. According to the Apple class reference, there are these properties:

  • placemark
  • isCurrentLocation
  • name
  • phone number
  • url

If I log an MKMapItem I get what appears as a JSON dictionary of dictionaries such as:

  • Address
  • structured address
  • center
  • locality
  • etc...

Many of the items contain information that I want, which are not default properties of MKMapItem. Is there a way to parse and model these items? I have tried

 NSDictionary *mapItemDictionary = (NSDictionary *)mapItem;

[mapItemDictionary valueForKey:@"key"];

, which results in a crash:

[<MKMapItem 0xb02d830> valueForUndefinedKey:]: this class is not key value coding-compliant for the key address.

Was it helpful?

Solution

Anna Karenina is correct...

MKmapItem *mapItem = mapItemResponseFromLocalSearch;

NSDictionary *itemAddressDictionary = mapItem.placemark.addressDictionary;

CLLocation *location = mapItem.placemark.location

NSString *name = mapItem.name
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top