Objective-C中trim的实现
Objective-C中trim的实现
在java,javascript中,都有trim的系统实现(将字符串的首尾空格去掉),但在iOS开发中,却没有找到现成的trim方法的实现,只有自己实现该方法了,下面是实现trim方法的实现:
- NSString *string = @" spaces in front and at the end ";
- NSString *trimmedString = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- NSLog(@"%@",trimmedString) ;
评论暂时关闭