【发布时间】:2012-10-31 14:23:44
【问题描述】:
在我的 iPhone 应用中,我有一系列的刺痛。
从那个字符串我需要获取第一个字符的数组。为此,我实现了如下逻辑。它有效,但在此我已经检索了 twicw 1.Small 字母和 2.Capital 字母的字符。
即使是小写字母,我也只需要大写字母。
like Only "A" for America, Africa and america, antantica
contactIndex = [[NSMutableArray alloc] init];
for (int i=0; i<[contactsArray count]-1; i++){
//---get the first char of each state---
char alphabet = [[contactsArray objectAtIndex:i] characterAtIndex:0];
NSString *uniChar = [NSString stringWithFormat:@"%C", alphabet];
//---add each letter to the index array---
if (![contactIndex containsObject:uniChar])
{
[contactIndex addObject:uniChar];
}
}
【问题讨论】:
标签: iphone objective-c ipad nsmutablearray nsarray