使用xcode的时区缩写列表

时间:2014-04-21 13:29:40

标签: ios timezone xcode5

我使用此功能检索了所有时区的列表,并将它们存储在数组中:

    timeZoneElements = [NSTimeZone knownTimeZoneNames] ;

我想获得缩写列表,例如:GMT + 1 ......有没有简单快捷的方法呢?很多谢谢

编辑1:此解决方案显示如下的时区:亚洲/贝鲁特...因此我需要显示GMT + 2标签..

1 个答案:

答案 0 :(得分:3)

试试这个,

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);