如何替换此行
[txtEmail.textstringByTrimmingCharactersInSet[NSCharacterSetwhitespaceAndNewlineCharacterSet]].length == 0`
任何功能。
if ([txtEmail.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length == 0 &&
[txtPassword.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length == 0)
{
}
else if ([txtEmail.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length == 0)
{
}
有什么建议吗?
答案 0 :(得分:1)
alternateWay


 txtEmail.text = [txtEmail.text stringByReplacingOccurrencesOfString:@“”withString:@“”];& #xA;
 if(txtEmail.text.length == 0)
 {
 // show alert
}
 else
 {
 //在这里做你的东西
}



 选项-2
&#xA ;
 if([txtEmail.text rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]]。location!= NSNotFound)
 {
 NSLog(@“white space found”);& #xA;}
 代码>


答案 1 :(得分:0)
NSRange range = [rawString rangeOfCharacterFromSet:whitespace];
if (range.location != NSNotFound) {
//whitespace Found.
}