gpt4 book ai didi

iPhone -- MKReverseGeocoder.adminstrativeArea -- 获取状态缩写

转载 作者:行者123 更新时间:2023-12-03 20:21:32 29 4
gpt4 key购买 nike

在 MKReverseGeocoder 的文档中,administrativeArea 属性为您提供用户当前所处的状态,并且在示例中提到它返回状态名称或其缩写。我想知道是否有人知道如何获取缩写而不是完整的州名...除了那个没有提到如何获取的简短示例之外,我找不到任何东西表明这甚至是一种可能性。

谢谢!

最佳答案

我还需要将 MKReverseGeocoder 中的 State 字段转换为两个字母的缩写,因此我创建了这个 plist:

https://github.com/djibouti33/US-State-Abbreviations

这是我的使用方法:

// in my initNSString *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;    }    ...}

关于iPhone -- MKReverseGeocoder.adminstrativeArea -- 获取状态缩写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2518381/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com