Remove all whitespaces from NSString
问题 I've been trying to get rid of the white spaces in an NSString , but none of the methods I've tried worked. I have "this is a test" and I want to get "thisisatest" . I've used whitespaceCharacterSet , which is supposed to eliminate the white spaces. NSString *search = [searchbar.text stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet]]; but I kept getting the same string with spaces. Any ideas? 回答1: stringByTrimmingCharactersInSet only removes characters from the