문제

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 ..

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top