Remove all whitespaces from NSString

后端 未结 11 1807
北荒
北荒 2020-12-04 06:23

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

11条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 07:15

    Easy task using stringByReplacingOccurrencesOfString

    NSString *search = [searchbar.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    

提交回复
热议问题