Ray*_*ayJ 2 iphone mkreversegeocoder
在MKReverseGeocoder的文档中,administrativeArea属性为您提供了用户所处的当前状态,并在示例中提到它返回EITHER状态名称或其缩写.我想知道是否有人知道如何获得缩写而不是完整的州名...我已经找不到任何表明这甚至可能除了那个简单的例子之外没有提及如何.
谢谢!
我还需要将状态字段从MKReverseGeocoder转换为两个字母的缩写,所以我创建了这个plist:
https://github.com/djibouti33/US-State-Abbreviations
这是我如何使用它:
// in my init
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"USStateAbbreviations" ofType:@"plist"];
self.usStateAbbreviations = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
// MKReverseGeocoder delegate method
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
...
NSString *state = [address objectForKey:@"State"];
NSString *stateAbbreviation = [self.usStateAbbreviations objectForKey:[state uppercaseString]];
NSString *stateTarget = state;
if (stateAbbreviation) {
stateTarget = stateAbbreviation;
}
...
}
| 归档时间: |
|
| 查看次数: |
1249 次 |
| 最近记录: |