标签:
写一个字符串扩展 #import "NSString+Additions.h"
//去掉首尾的空格 判断字符串是否为空
+(BOOL) isEmpty {
return nil == self
|| 0 == [[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length];
}
//去掉字符串首尾的空格
-(NSString *)trim{
return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
//移除字符串中所有空格
- (NSString*)removeAllSpace
{
NSString* result = [self stringByReplacingOccurrencesOfString:@" " withString:@""];
result = [result stringByReplacingOccurrencesOfString:@" " withString:@""];
return result;
}
标签:
原文地址:http://www.cnblogs.com/huangzs/p/4583256.html