Possible Duplicate:
Remove double quotes from NSString
I have a string with double double quotes “” that I need to replace with single double quotes “.
I’ve tried the following but I still end up with double double quotes
NSString *str = @"This is a \"\"99\"\" string";
[str stringByReplacingOccurrencesOfString: @"\"\"" withString: @"\""];
Initially the string is: This is a “”99″” string
After the stringByReplacingOccurrencesOfString: This is a “”99″” string.
What am I doing wrong?
It looks like you are expecting
strto contain your modified string. Instead, you should be looking at the return value of thestringByReplacingOccurrencesOfString:withString:function:NSString objects are immutable. If you want str to be mutable, look into NSMutableString: documentation link