Wednesday, January 12, 2011

Loop alphabet objective c

Objective C makes it easy:

NSMutableArray *alphabetArray;
alphabetArray = [[NSMutableArray alloc] init];
for(char c = 'A'; c <= 'Z'; c++)
{
[alphabetArray addObject:[NSString stringWithFormat:@"%c", c]];
}

Or if you want to do lower case:

NSMutableArray *alphabetArray;
alphabetArray = [[NSMutableArray alloc] init];
for(char c = 'a'; c <= 'z'; c++)
{
[alphabetArray addObject:[NSString stringWithFormat:@"%c", c]];
}

No comments:

Post a Comment