-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
[self.map removeAnnotations:self.map.annotations];
if ([textField isEqual:self.searchText]) {
NSPredicate *bPredicate =
[NSPredicate predicateWithFormat:@"name contains[c], %@",self.searchText.text];
self.filteredArray = [self.hotelArray filteredArrayUsingPredicate:bPredicate];
NSLog(@" HEARE %@",self.filteredArray);
[self markAllHotels];
}
return YES;
}
hotelArray and filteredArray are NSArrays.
hotelArray has objects of type hotel where hotel has a property name.
Problem :
I want to filter hotelArray according to hotel.name when hotel.name matches text entered in searchText [text field], but I am getting an empty self.filteredArray.