Procházet zdrojové kódy

Update search results when a new network request matching the search term comes in.

Ryan Olson před 11 roky
rodič
revize
f4106e4be5

+ 12 - 3
Classes/Network/FLEXNetworkHistoryTableViewController.m

@@ -70,6 +70,10 @@
 {
     [self updateTransactions];
     [self.tableView reloadData];
+
+    if (self.searchController.isActive) {
+        [self updateSearchResultsWithSearchString:self.searchController.searchBar.text];
+    }
 }
 
 #pragma mark - Table view data source
@@ -125,6 +129,14 @@
 #pragma mark - Search display delegate
 
 - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
+{
+    [self updateSearchResultsWithSearchString:searchString];
+
+    // Reload done after the data is filtered asynchronously
+    return NO;
+}
+
+- (void)updateSearchResultsWithSearchString:(NSString *)searchString
 {
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         NSArray *filteredNetworkTransactions = [self.networkTransactions filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(FLEXNetworkTransaction *transaction, NSDictionary *bindings) {
@@ -137,9 +149,6 @@
             }
         });
     });
-
-    // Reload done after the data is filtered asynchronously
-    return NO;
 }
 
 @end