2012-04-22 13 views

答えて

4

あなたはこれを試すことができます:ここ

NSString *string = @" spaces in front and at the end "; 
NSString *trimmedString = [string stringByTrimmingCharactersInSet: 
           [NSCharacterSet whitespaceAndNewlineCharacterSet]]; 

キーアップルdocからwhitespaceAndNewlineCharacterSet、されています

Returns a character set containing only the whitespace characters space (U+0020) and tab (U+0009) and the newline and nextline characters (U+000A–U+000D, U+0085). 
+0

はい、私はこの方法を知っています。しかし、私はちょうど "中間のスペース"のように私たちの文字列の真ん中に空白をトリムしたい –

+0

それは、ありがとう、働く。 –

関連する問題