如何删除NSString中的撇号和空格

Mar*_*rio 0 iphone objective-c nsstring

NSString *str = @"mario's test";
NSString *stringWithoutSpaces = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
Run Code Online (Sandbox Code Playgroud)

使用此功能,我可以删除空格,但我还需要删除撇号':

stringWithoutSpaces = "mariostest"
Run Code Online (Sandbox Code Playgroud)

小智 5

*stringWithoutSpaces = [[str stringByReplacingOccurrencesOfString:@" " withString:@""]
                             stringByReplacingOccurrencesOfString:@"'" withString:@""]; 
Run Code Online (Sandbox Code Playgroud)