为什么rangeOfString在if语句中不再适用于5.1模拟器

时间:2012-08-13 18:53:04

标签: objective-c ios if-statement

为什么这不适用于5.1模拟器,但是在4.2 4.3 5.0 ???

中工作

OSXLion 10.7.4 XCode 4.3.3

 if ([email.text rangeOfString:@"@"].location == NSNotFound) {

    UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Email" message:@"Please provide email address" delegate:nil cancelButtonTitle:@"Cool" otherButtonTitles:nil];
    [alert show];

}
else {
    work...work...work...

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

如果您确认电子邮件地址不包含@,则听起来模拟器可能正在运行旧版本的代码。我建议清理您的项目和模拟器的resetting the contents and settings。要重置模拟器,当它是最前面的打开应用程序时,请选择 iOS模拟器 > 重置内容和设置