我使用这个函数检索了所有时区的列表,并将它们存储在一个数组中:
timeZoneElements = [NSTimeZone knownTimeZoneNames] ;
我想得到缩写的列表,例如:GMT+1…有什么简单快捷的方法吗
非常感谢
编辑1:此解决方案显示时区如下:亚洲/贝鲁特…因此,我需要显示GMT+2标签。。
试试这个,
NSMutableArray *timeZoneArray = [[NSMutableArray alloc] initWithArray:[NSTimeZone knownTimeZoneNames]];
NSMutableArray *abbreviationArray = [[NSMutableArray alloc] init];
for (int count=0; count < [timeZoneArray count]-1; count=count+1)
{
[abbreviationArray addObject:[[NSTimeZone timeZoneWithName:[timeZoneArray objectAtIndex:count]] abbreviation]];
}
NSLog(@"Abbreviation : %@",abbreviationArray);