MapKit を使用して、1 つ以上の MKMapItem オブジェクトを返すローカル検索を実行しています。しかし、デバッガーで表示できるオブジェクトのメンバーがありますが、アクセスできません。特に必要なのは UID です。
item.placemark を試しましたが、UID にアクセスできません。これは本当に単純なはずです。ここで何が欠けていますか?
これは機能しません: NSString *uid = item.placemark.UID
これは動作しません:
NSDictionary *mapItemDictionary = (NSDictionary *)item;
NSString *uid = [mapItemDictionary objectForKey:@"UID"];
しかし、デバッガー コマンドの po item には、オブジェクトのすべてのメンバーが表示されます。
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";
}
);
これについての助けをいただければ幸いです。私が使用しているコードは次のとおりです。
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 is NIL
NSString *uid=nil;
if (businessArray != nil && businessArray.count >0) {
NSDictionary *businessDict=businessArray[0];
uid=businessDict[@"UID"];
}
NSLog(@"UID is %@",uid);
}];