这就是我得到的
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't do regex matching on object <UITextField: 0x7165730; frame = (121 208; 179 30); text = 'mail@test.com'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7166ca0>; layer = <CALayer: 0x715ed50>>.'
*** First throw call stack:
(0x1c94012 0x10d1e7e 0xbfbb5e 0xb38bae 0xb383dc 0xb37e9a 0x3c04 0x29a9 0x10e5705 0x1c920 0x1c8b8 0xdd671 0xddbcf 0xdcd38 0x4c33f 0x4c552 0x2a3aa 0x1bcf8 0x1befdf9 0x1befad0 0x1c09bf5 0x1c09962 0x1c3abb6 0x1c39f44 0x1c39e1b 0x1bee7e3 0x1bee668 0x1965c 0x1f95 0x1e95)
libc++abi.dylib: terminate called throwing an exception
抱歉,如果太大,但我不明白那个错误,我从 .xib Autolayout 中禁用,因为这使我的应用程序在旧设备中崩溃,我的应用程序从未在该 TextField 中崩溃,这是电子邮件的文本字段。
提前致谢。
编辑:
我的代码:
NSString *mail = [email.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if ([self validarEmail:mail])
{
// code
}
-(BOOL) validarEmail:(NSString *) mail // From internet made for objective-c
{
BOOL stricterFilter = YES;
NSString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSString *laxString = @".+@.+\\.[A-Za-z]{2}[A-Za-z]*";
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
如果我评论 IF 应用程序会正常,否则会崩溃。
提前致谢