How to remove whitespace in a string?

后端 未结 13 2161
天涯浪人
天涯浪人 2020-12-17 08:12

I have a string say \"Allentown, pa\"

How to remove the white space in between , and pa using objective c?

13条回答
  •  旧巷少年郎
    2020-12-17 08:32

    you can use remove function to remove any substring from the string

    - (NSString*)remove:(NSString*)textToRemove fromString:(NSString*)input { 
        return [input stringByReplacingOccurrencesOfString:textToRemove withString:@""]; 
    }
    

提交回复
热议问题