NSMutableString *stringa = [[NSMutableString alloc] initWithFormat:@"%@", surnameField.text];
if ([stringa length] < 3) {
[stringa appendString:@"x"];
}
NSMutableString *consonanti = [[NSMutableString alloc] init];
NSCharacterSet *vocali = [NSCharacterSet characterSetWithCharactersInString:@"aeiouàèìòùáéíóúAEIOUÀÈÌÒÙÁÉÍÓÚ"];
NSRange r;
for (int i=0; i < [stringa length]; i++) {
r = [stringa rangeOfCharacterFromSet:vocali];
if (r.location != NSNotFound) {
[consonanti appendFormat:@"%c",[stringa characterAtIndex:i]];
}
else {
}
}
cfField.text = consonanti;
[stringa release];
[consonanti release];
The result of cfField.text is always consonants with vowels, while the result must be only consonants. I don't know.