How do you test if an NSString is empty
-(BOOL) isEmptyString:(NSString*) string {
if([string length]==0){//string is empty or nil
return YES;
}elseif([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0){
//string is all whitespace
return YES;
}
return NO;
}
签名:删除冗余的代码最开心,找不到删除的代码最痛苦!