Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
749 views
in Technique[技术] by (71.8m points)

objective c - Remove double quotes from NSString

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the NSMakeRange function instead of your cast. This'll work:

[mString replaceOccurrencesOfString:@""" withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mString length])];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...