Is there a way to perform one code if either of two things happen? Specifically, I have 2 TextFields, and if any of them is empty, I want to popup UIAlertView when action is performed. I can set
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];
}
but if both are empty, it will pop up the statement 2 times.
How can I get it to popup only once if either, or both are empty?
You can combine the two conditions into a single
ifstatement using the||(or) operator.