Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove quotes from an NSString?

I am trying to remove quotes from something like:

"Hello"

so that the string is just:

Hello

like image 987
Andrew Avatar asked Nov 08 '10 05:11

Andrew


1 Answers

Check out Apple's docs:

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/

You probably want:

stringByReplacingOccurrencesOfString:withString:

Returns a new string in which all occurrences of a target string in the receiver are replaced by another given string.

- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement

So, something like this should work:

newString = [myString stringByReplacingOccurrencesOfString:@"\"" withString:@""];
like image 106
Nathan S. Avatar answered Nov 15 '22 06:11

Nathan S.