Is there an easy way to programmatically get the alphabet?

前端 未结 5 1360
臣服心动
臣服心动 2021-02-04 12:11

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

5条回答
  •  遥遥无期
    2021-02-04 13:02

    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];
    

提交回复
热议问题