设为首页 加入收藏

TOP

【代码笔记】iOS-判断字符串是否为空
2017-10-13 10:29:16 】 浏览:5656
Tags:代码 笔记 iOS- 判断 字符串 是否

一,代码。

复制代码
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title=@"判断字符串是否为空";
    
    NSLog(@"-isEmpty--%i--",[self isEmpty:@"123"]);
    
}

//判断字符串是否为空
-(BOOL)isEmpty:(NSString *)str
{
    if(!str)
    {
        return true;
    }
    else
    {
        NSCharacterSet *set=[NSCharacterSet whitespaceAndNewlineCharacterSet];
        NSString *trimedString=[str stringByTrimmingCharactersInSet:set];
        if([trimedString length]==0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
复制代码

 

二,输出。

2015-10-19 15:38:15.642 判断字符串是否为空[9406:236480] -isEmpty--0--

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇ios开发之UIScrollView的三个属性.. 下一篇[iOS] WSHorizontalPickerView 图..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目