Alex Rivera | Logout

Is there an easy way to programmatically get the alphabet?

Asked 2010-12-07T14:52:08.440
10

I want an NSArray/NSMutableArray containing all the letters of the alphabet. There must be a quick and easy way, better than typing them all out. For example in PHP:

foreach(range('A','Z') as $i) $alphabet[]=$i;
Edit
Report

2 Answers

4

try with following code;


int a = 65;
for (; a < 91; a++) {
    [array addObject:[NSString stringWithFormat:@"%c", (char)a]];
}
NSLog(@"%@", array);
answered 2010-12-07T15:20:58.830
0

You could use a for-loop to generate them, but I think typing them out is easier. It is most certainly easier than posting a question here. ;)

answered 2010-12-07T14:56:33.297

Your Answer