Try this:
- (void) checkTextFields
{
if ([self.nameTextField.text length] != 0 && [self.itemTextField.text length] != 0 && [self.occasionTextField.text length] != 0 && ([self.isReceivedSegment selectedSegmentIndex] == 0 || [self.isReceivedSegment selectedSegmentIndex] == 1))
{
NSLog(@"This shouldn't be run if not every field is filled in");
self.saveButton.enabled = TRUE;
}
else
{
NSLog(@"Run");
self.saveButton.enabled = FALSE;
}
}
The way you have implemented your conditions, with the parentheses, it will evaluate true when your selectedSegmentIndex = 1, regardless of the other conditions. Moving around the parentheses like so should work.
Notice that I have moved the parentheses to surround the OR portion of your conditions.
EDIT add these lines to your view did load method to have the form be checked after editing any text field.
[nameTextField addTarget:self action:@selector(checkTextFields) forControlEvents:UIControlEventEditingChanged];
[itemTextField addTarget:self action:@selector(checkTextFields) forControlEvents:UIControlEventEditingChanged];
[occasionTextField addTarget:self action:@selector(checkTextFields) forControlEvents:UIControlEventEditingChanged];