#pragma mark 检验输入框为空以及输入参数只有空格的判断 Yes:是空白,或者为空 NO:不是空白
-(BOOL)isEmpty:(NSString *)str{
if (str) {
//A character set containing only the whitespace characters space (U+0020) and tab (U+0009) and the newline and nextline characters (U+000A–U+000D, U+0085).
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
//Returns a new string made by removing from both ends of the receiver characters contained in a given character set.
NSString *trimedString = [str stringByTrimmingCharactersInSet:set];
if ([trimedString length] == 0) {
return YES;
} else {
return NO;
}
}else{
return YES;
}
}
检验输入框为空以及输入参数只有空格的判断
最新推荐文章于 2017-07-26 10:01:18 发布