In my iPhone app i have an array of stings.
fron that string i need to get the array of first charecters. For this i have implemented logic as follow. it works but in this i have retrieve charectes twicw 1.Small letters and 2.Capital letters.
I need to get only capital letters even it is the small letter.
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];
}
}
See the Example, This will work