2 つのいずれかが発生した場合に 1 つのコードを実行する方法はありますか? 具体的には、2 つの TextFields があり、それらのいずれかが空の場合、アクションが実行されたときに 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 回ポップアップします。
どちらか、または両方が空の場合、一度だけポップアップさせるにはどうすればよいですか?