I am manipulating a large string by removing chunks of characters, and assigning the new string back to the original string.
articleString = [articleString stringByReplacingCharactersInRange:startRange withString:@""];
articleString is an instance variable of type NSMutableString
This seems to work fine the first time I go through this code. But when I return from the second time through, and use the variable articleString, I get an EXC_BAD_ACCESS exception.
These are long strings – up to 100K bytes.
Any ideas why I am getting the exception?
stringByReplacingCharactersInRange:startRange would return a copy of type NSString. (Not NSMutableString)
you want to use:
– (void)replaceCharactersInRange:(NSRange)aRange withString:(NSString *)aString instead.
stringByReplacingCharactersInRange:startRange returns an autoreleased NSString so you would have to call retain on it if articleString is a member variable.