- (BOOL)checkUsername { NSString * regex = @"^[A-Za-z0-9]{1,15}$";
//正则表达式 NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
//Cocoa框架中的NSPredicate用于查询,原理和用法都类似于SQL中的where,作用相当于数据库的过滤取 BOOL isMatch = [pred evaluateWithObject:userNameField.text];
//判读userNameField的值是否吻合
return isMatch; }
- (BOOL)checkPassword { NSLog(@"passsowrd:%@",passwordField.text); if (passwordField.text.length > 0) { return YES; } return NO; }