iOS MKMapItem - how get access to all members? -
iOS MKMapItem - how get access to all members? -
i using mapkit local search returns 1 or more mkmapitem objects. there members of object can see in debugger can't access. 1 particularly need uid.
i have tried item.placemark, not allow me access uid. seems should simple. missing here?
this not work: nsstring *uid = item.placemark.uid
this not work:
nsdictionary *mapitemdictionary = (nsdictionary *)item; nsstring *uid = [mapitemdictionary objectforkey:@"uid"];
but debugger command po item shows me members of object:
name: shell currentlocation: 0 place: <geoplace: 0x17014e650> { address = { business = ( { **uid = 2478578482074921045**; url = "www.shell.com"; canbecorrectedbybusinessowner = 1; name = shell; source = ( { "source_id" = a3h0281540; "source_name" = "acxiom_us"; }, { "source_id" = 2276257; "source_name" = localeze; } ); telephone = "+14803968213"; } );
any help appreciated. here code i'm using:
mklocalsearch *localsearch = [[mklocalsearch alloc] initwithrequest:request]; [localsearch startwithcompletionhandler:^(mklocalsearchresponse *response, nserror *error) { [response.mapitems enumerateobjectsusingblock:^(mkmapitem *item, nsuinteger idx, bool *stop) { mkplacemark *placemark = (mkplacemark *)item.placemark; nsdictionary *addressdict = placemark.addressdictionary; nsarray *businessarray = addressdict[@"business"];// businessarray nil nsstring *uid=nil; if (businessarray != nil && businessarray.count >0) { nsdictionary *businessdict=businessarray[0]; uid=businessdict[@"uid"]; } nslog(@"uid %@",uid); }];
ok, after lot of digging seems info in couple of private objects. "place" property geoplace, , has property, business, array contains geobusiness object. since private info cannot access straight via properties, can via key-value encoding. next code extracts uid -
[response.mapitems enumerateobjectsusingblock:^(mkmapitem *item, nsuinteger idx, bool *stop) { nsvalue *place = [item valueforkey:@"place"]; nsarray *businessarray = (nsarray *)[place valueforkey:@"business"]; nsnumber *uid=nil; if (businessarray != nil && businessarray.count >0) { id geobusiness=businessarray[0]; uid=[geobusiness valueforkey:@"uid"]; } nslog(@"uid %@",[uid stringvalue]); }];
as private info structures there no guarantee won't change. unsure whether app store validation process flag private api access - since using valueforkey
don't think will, there no guarantees.
ios mkmapitem
Comments
Post a Comment