今天由于要写一个工具转码处理字符串,于是就没有导入自己的pod,结果字符串一直出现<object returned empty description>
,各种判断没有效果,也不想导入自己的pod,因为项目太小了用pods太小题大做了,于是就在网上找了找,结果真的是都不管用,,于是还是秒自己之前给NSString写的一个分类,分分钟见效
/// 是否为空或者是空格
- (BOOL)isEmpty ///< 是否为空或者是空格
{
NSString * newSelf = [self stringByReplacingOccurrencesOfString:@" " withString:@""];
if(nil == self
|| self.length ==0
|| [self isEqualToString:@""]
|| [self isEqualToString:@"<null>"]
|| [self isEqualToString:@"(null)"]
|| [self isEqualToString:@"null"]
|| newSelf.length ==0
|| [newSelf isEqualToString:@""]
|| [newSelf isEqualToString:@"<null>"]
|| [newSelf isEqualToString:@"(null)"]
|| [newSelf isEqualToString:@"null"]
|| [self isKindOfClass:[NSNull class]] ){
return YES;
}else{
// <object returned empty description> 会来这里
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *trimedString = [self stringByTrimmingCharactersInSet:set];
return [trimedString isEqualToString: @""];
}
return NO;
}