FLEXTool / FLEX

An in-app debugging and exploration tool for iOS
Other
14.06k stars 1.7k forks source link

Multi-filter support in Classes Search. #211

Closed hiburn8 closed 6 years ago

hiburn8 commented 6 years ago

I think being able to supply multiple search-terms in the classes filter would be very useful. I often find it hard to quickly find the class i want in large apps.

I wont make a pull request since my ObjC is awful, but this change can be made in method - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText here: FLEX/blob/master/Classes/GlobalStateExplorers/FLEXClassesTableViewController.m using something like the following; i think:


- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    if ([searchText length] > 0) {
        NSArray *searchArray = [searchText componentsSeparatedByString: @" "];
        int index = 0;

        for (id searchItem in searchArray) {
            NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", searchItem];
            if (index == 0){
                self.filteredClassNames = [self.classNames filteredArrayUsingPredicate:searchPredicate];
            }
            else{
                self.filteredClassNames = [self.filteredClassNames filteredArrayUsingPredicate:searchPredicate];
            }

            index++;
        }
    } else {
        self.filteredClassNames = self.classNames;
    }
    [self updateTitle];
    [self.tableView reloadData];
}

Note: using a space char to delimit search-terms since its not valid in class names

hiburn8 commented 6 years ago

Also a nice opportunity to fix the typo in this method on lines 81,82: searchPreidcate