字符串判断
2016-05-25 10:55
295 查看
第一种判断不为空
- (BOOL)isBlankString:(NSString *)string {
if (string
== nil || string == NULL)
{
return YES;
}
else if ([string isKindOfClass:[NSNull class]])
{
return YES;
}
else if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0)
{
return YES;
}
return NO;
}
第二种判断不为空
-(BOOL)isEmptyString:(NSString *) str {
if (!str) {
return YES;
} else {
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *trimedString = [str stringByTrimmingCharactersInSet:set];
if ([trimedString length] == 0) {
return YES;
} else {
return NO;
}
}
}
- (BOOL)isBlankString:(NSString *)string {
if (string
== nil || string == NULL)
{
return YES;
}
else if ([string isKindOfClass:[NSNull class]])
{
return YES;
}
else if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0)
{
return YES;
}
return NO;
}
第二种判断不为空
-(BOOL)isEmptyString:(NSString *) str {
if (!str) {
return YES;
} else {
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *trimedString = [str stringByTrimmingCharactersInSet:set];
if ([trimedString length] == 0) {
return YES;
} else {
return NO;
}
}
}
相关文章推荐
- 数据库ORACLE中函数decode的用法
- at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
- swift UIView 扩展
- Lucene(未查找)
- 基于 JQUERY 网页 banner
- nginx模块
- linux__kickstart无人值守批量安装系统
- 关于Android Lollipop
- 343. Integer Break #Medium
- eclipse 指定文件上传到tomcat的路径
- 回归 ---- 线性回归,多元回归与逻辑回归的关系
- 287. Find the Duplicate Number
- SQL Server native client与sqlcmd单独安装
- android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open dat
- Unity固定管线shader总结
- 触摸屏手势控制镜头旋转与缩放
- 操作符重载
- 高德、百度、Google地图定位偏移以及坐标系转换
- codeforces (G) The Debut Album dp+滚动数组
- mce-inject使用方法