I have qtyTextFields that are added to a custom UITableViewCell dynamically.
What I am trying to do is detect if the user has inputted the string 0 in the UITextField and removing an object from an NSMutableArray if so. (I get how to remove the object from the NSMutableArray thats fine)
This implementation below does nothing for me and doesn’t even log anything:
-(void)textFieldDidEndEditing:(UITextField *)textField{
if ([qtyTextField.text isEqualToString: @"0"])
{
NSLog(@"You ENTERED 0");
[theProducts removeObjectAtIndex:qtyTextField.tag];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"basket.plist"];
[theProducts writeToFile:path atomically:YES];
}
else
{
NSLog(@"Do Nothing");
}
[self.tableView reloadData];
}
}
Have you tried using the UITextField instance you get from the method? so the if statement would read: