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;
The array generated for table index titles may also be used. It does not use a for
loop and has multi-language support.
NSMutableArray *alphabets = [[NSMutableArray alloc] initWithArray:[[UILocalizedIndexedCollation currentCollation] sectionIndexTitles]];
//Remove the last object (extra), '#' from the array.
[alphabets removeLastObject];
There's no quicker way than typing them all out, unless you cut and paste my handy reference from below!
"abcdefghijklmnopqrstuvwxyz"
For the sake of it, here's a longer way.
for (char a = 'a'; a <= 'z'; a++)
{
[myArray addObject:[NSString stringWithFormat:@"%c", a]];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With