The issue is happening in this method below, You have 3 text fields and all of them call this method but you assume this is happened just for self.nameTextField:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
self.autoCompleteTableView.hidden = NO;
self.substring = [NSString stringWithString:self.nameTextField.text];
self.substring = [self.substring stringByReplacingCharactersInRange:range withString:string];
NSLog(@"Value of entered string = %@", self.substring);
[self searchAutocompleteEntriesWithSubstring:self.substring];
return YES;
}
You can fix it in many ways, it depends what is required for you, one of them is compare that edited text field is your self.nameTextField, but I don't know is it whay you want to achieve:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (self.nameTextField == textField)
{
self.autoCompleteTableView.hidden = NO;
self.substring = [NSString stringWithString:self.nameTextField.text];
self.substring = [self.substring stringByReplacingCharactersInRange:range withString:string];
NSLog(@"Value of entered string = %@", self.substring);
[self searchAutocompleteEntriesWithSubstring:self.substring];
}
return YES;
}