I have a string that ends with a ” (quotation mark) that I want to get rid of. However, because XCode usually requires you to enter the text you wish to remove using stringByReplacingOccurrencesOfString in @”texttoremove” format, you can’t use the quotation marks in the space as it thinks you are closing the text.
Update: Now I can’t get rid of “\n\t\t that’s at the end of each string. Any ideas?
Any ideas on how I can do it?
Thanks.
To enter a quote in an Objective-C string you just have to escape it with a ‘\’. So a string containing just a quote is:
Update:
Within a string literal, “\n” and “\t” are escape sequences identifying the newline and tab characters respectively. I assume you mean the string ends with a newline & 2 tabs, not literal ‘\’ and ‘n’ characters….
You probably want to use stringByTrimmingCharactersInSet:, for example:
(Note that this will trim whitespace at both ends)