Guest User

Untitled

a guest
Jan 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  2. {
  3. [searchResults removeAllObjects];
  4.  
  5. if ([searchText length] > 0) {
  6.  
  7. NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
  8. NSRange range = [[evaluatedObject name] rangeOfString:searchText];
  9. if (range.location != NSNotFound) {
  10. return YES;
  11. }
  12. return NO;
  13. }];
  14. searchResults = [[storesData filteredArrayUsingPredicate:predicate] mutableCopy];
  15.  
  16. }
  17. else
  18. {
  19. searchResults = [storesData copy];
  20. }
  21.  
  22. [storesTableView reloadData];
  23. }
Add Comment
Please, Sign In to add comment