Hello,
First off, I’m a complete newly to coding, so I apologize if I am missing something super simple. I am getting an error code: “Thread 1:EXC_BAD_ACCESS (code=2, address=0x7fff5f3fffe8” on the last NSLog line of the following code. I’m sure I am just missing some simple letter I typed wrong, but I am not finding it. Thanks for any help!
[code] // Create an array of strings to devowelize and a container for new ones
NSArray *oldStrings = [NSArray arrayWithObjects:@“Sauerkraut”, @“Raygun”, @“Big Nerd Ranch”, @“Missippippi”, nil];
NSLog(@“old strings: %@”, oldStrings);
NSMutableArray *newStrings = [NSMutableArray array];
// Create a list of vowels we will remove from the string
NSArray *vowels = [NSArray arrayWithObjects:@"a", @"e", @"i", @"o", @"u", nil];
// Declare the block variable
void (^devowelizer) (id, NSUInteger, BOOL *);
// Assign a block to the variable
devowelizer = ^(id string, NSUInteger i, BOOL *stop){
NSMutableString *newString = [NSMutableString stringWithString:string];
// Iterate over the array of vowels, replacing occurances of each
// with an emplty string
for (NSString *s in vowels) {
NSRange fullRange = NSMakeRange(0, [newString length]);
[newString replaceOccurrencesOfString:s
withString:@""
options:NSCaseInsensitiveSearch
range:fullRange];
}
[newStrings addObject:newStrings];
}; // End of block assignment
// Iterate over the array with our block
[oldStrings enumerateObjectsUsingBlock:devowelizer];
NSLog(@"new strings: %@", newStrings);
/code]