I'm having some trouble adding a mutable string (that has been changed with replaceOccurrencesOfString) to an array. This is related to another question I asked: http://stackoverflow.com/questions/2124860/remove-double-quotes-from-nsstring
Here is the code
//original String
NSString *aString = @"\"Hello World\"";
NSLog(@"Original String: %@",aString);
//craete mutable copy
NSMutableString *mString = [aString mutableCopy];
//remove quotes
[mString replaceOccurrencesOfString:@"\"" withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [aString length])];
NSLog(@"Mutable String: %@",mString);
//add to an array
NSArray *anArray = [NSArray arrayWithObject:mString];
NSLog(@"anArray: %@",anArray);
And the result:
2010-01-25 09:01:15.644 Quotes[20058:a0f] Original String: "Hello World"
2010-01-25 09:01:15.662 Quotes[20058:a0f] Mutable String: Hello World
2010-01-25 09:01:15.663 Quotes[20058:a0f] anArray: (
"Hello World"
)
a As you can see, the string is removed of the quotes in mString but when it's added to the array, it still has the double quotes. Any thoughts?