NSString *str = @"mario's test";
NSString *stringWithoutSpaces = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
使用此功能我可以删除空格,但我还需要删除撇号'
:
stringWithoutSpaces = "mariostest"
答案 0 :(得分:5)
*stringWithoutSpaces = [[str stringByReplacingOccurrencesOfString:@" " withString:@""]
stringByReplacingOccurrencesOfString:@"'" withString:@""];