level 1
我是一个萝卜9
楼主
关于在IOS 开发环境中,如何判断一个字符串是否为空,下面杭州达内小编通过一小段代码来具体演示给大家: NSString *trimedString = [textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([trimedString length] == 0) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告" message:@"搜索内容不能为空" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
[alert release];
return true;
}
以上方法,我个人大致过了一遍,可行,目前没有发现什么问题,欢迎志同道合人士共同探讨,有没有其他的更好更高效的方法,就当是共同学习了吧。
2013年05月11日 06点05分
1
if ([trimedString length] == 0) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告" message:@"搜索内容不能为空" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
[alert release];
return true;
}
以上方法,我个人大致过了一遍,可行,目前没有发现什么问题,欢迎志同道合人士共同探讨,有没有其他的更好更高效的方法,就当是共同学习了吧。