objective-C 中类似于C#中trim的方法(去掉字符串前后空格)

在objective-c中去掉字符串前后空格的方法(类似于C#中的trim方法)如下:

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

posted @ 2011-01-10 13:35  鬼手如冰  阅读(3606)  评论(0编辑  收藏  举报