如果发生两件事中的任何一件,有没有办法执行一个代码?具体来说,我有 2 个 TextField,如果其中任何一个为空,我想在执行操作时弹出 UIAlertView。我可以设置
if ([myTextField.text length] == 0) {
NSLog(@"Nothing There");
UIAlertView *nothing = [[UIAlertView alloc] initWithTitle:@"Incomplete" message:@"Please fill out all fields before recording" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[nothing show];
[nothing release];
}
if ([yourTextField.text length] == 0) {
NSLog(@"Nothing For Name");
UIAlertView *nothing = [[UIAlertView alloc] initWithTitle:@"Incomplete" message:@"Please fill out all fields before recording" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[nothing show];
[nothing release];
}
但如果两者都为空,则会弹出该语句 2 次。
如果其中一个或两个都为空,我怎样才能让它只弹出一次?