使用 xcode 的时区缩写列表 [英] List of timezone abbreviations using xcode

查看:33
本文介绍了使用 xcode 的时区缩写列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个函数检索了所有时区的列表并将它们存储在一个数组中:

I have retrieved a list of all the time zones using this function and storing them in an array :

    timeZoneElements = [NSTimeZone knownTimeZoneNames] ;

我想获取缩写列表,例如:GMT+1 ……有什么简单快捷的方法可以做到吗?
非常感谢

I want to get the list of abbreviations , for example : GMT+1 … is there any easy and quick way to do that ?
Many thanks

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

Edit 1 : This solution shows the timezones like follows : Asia/Beirut … therefore i need to show instead the GMT+2 label ..

推荐答案

试试这个,

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

这篇关于使用 xcode 的时区缩写列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆