iOS MKMapItem - how get access to all members?

好久不见. 提交于 2019-12-06 16:38:09

Ok, so after a lot of digging it seems that the information is in a couple of private objects. The "place" property is a GEOPlace, and this has a property, business, which is an array that contains a GEOBusiness object. Since this is private data you cannot access it directly via properties, but you can get it via key-value encoding. The following code extracts the 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 is %@",[uid stringValue]);

 }];

As this is private data structures there is no guarantee that it won't change. I am also unsure whether the App store validation process will flag this as private api access - Since it is using valueForKey I don't think it will, but there are no guarantees.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!