How do I remove double quotes from an NSString. Example:
//theMutableString: "Hello World"
[theMutableString replaceOccurrencesOfString:@"\"" withString:@"" options:NSCaseInsensitiveSearch range:(NSRange){0,[theMutableString length]}]
It doesn't seem to work, maybe since I had to escape the " in the replaceOccurrencesOfString?
Use the
NSMakeRange
function instead of your cast. This'll work:Assuming the mString bit is a typo. I ran this code and the answer was as expected
Output
So it mString was a typo in your question, then your code is correct and the problem is elsewhere. If mString is a typo in your code than that would be the issue.
What happens if you use
NSMakeRange(0, [theMutableString length])
instead of trying to cast an inline struct?You can use
I works perfectly on my end (I copy-pasted your replace line), with both NSMakeRange and the inline struct cast. Are you sure the quotes in your NSString are really the ASCII character 0x22?
How about this ?