问题
I have retrieved a list of all the time zones using this function and storing them in an array :
timeZoneElements = [NSTimeZone knownTimeZoneNames] ;
I want to get the list of abbreviations , for example : GMT+1 … is there any easy and quick way to do that ?
Many thanks
Edit 1 : This solution shows the timezones like follows : Asia/Beirut … therefore i need to show instead the GMT+2 label ..
回答1:
Try This,
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);
来源:https://stackoverflow.com/questions/23198439/list-of-timezone-abbreviations-using-xcode