Not much to think about here, but here is mine anyway
[code]int main(int argc, const char * argv[]) {
@autoreleasepool {
// Create one array of strings to iterate through
NSArray *originalStrings = @[@"SauerKraut", @"Raygun", @"Big Nerd Ranch", @"Mississippi"];
NSLog(@"Original Strings: %@", originalStrings);
// Create array container for devowelized ones
NSMutableArray *devowelizedStrings = [NSMutableArray array];
// Create array with list of vowels/characters
NSArray *vowels = @[@"a", @"e", @"i", @"o", @"u"];
// Iterate over the array with an anonymous BLOCK
[originalStrings enumerateObjectsUsingBlock:
^(id string, NSUInteger i, BOOL *stop){
NSMutableString *newString = [NSMutableString stringWithString:string];
/*NSRange yRange = [string rangeOfString:@"y"
options:NSCaseInsensitiveSearch];
if (yRange.location != NSNotFound) {
*stop = YES;
return;
}*/
for (NSString *s in vowels) {
NSRange fullRange = NSMakeRange(0, newString.length);
[newString replaceOccurrencesOfString:s
withString:@""
options:NSCaseInsensitiveSearch
range:fullRange];
}
[devowelizedStrings addObject:newString];
}];
NSLog(@"Devowelized Strings: %@", devowelizedStrings); // output devowelized array
}
return 0;
}
[/code]
[color=#4000FF]************** OUTPUT ***************
2014-12-10 22:15:02.499 ObjC_Anonymous_Blocks - Challenge[4646:909370] Original Strings: (
SauerKraut,
Raygun,
“Big Nerd Ranch”,
Mississippi
)
2014-12-10 22:15:02.500 ObjC_Anonymous_Blocks - Challenge[4646:909370] Devowelized Strings: (
SrKrt,
Rygn,
“Bg Nrd Rnch”,
Msssspp
)
Program ended with exit code: 0[/color]