可能重複:
Replacing one character in a string in Objective-C
Remove all whitespace from NSString如何從一個字符串中的iOS刪除空格
@"this string contains blank spaces"
。
我們該如何將此字符串轉換爲@"thisstringcontainsblankspaces"
。
我的意思是我們如何修剪一個字符串中的所有空格和換行符。我已經通過使用whitespaceCharacterSet
嘗試過NSCharecterSet
。但是這隻能刪除字符串末端的空格,而不能在兩個字符之間......
任何想法?