Przeglądaj źródła

Add convenience method for getting the network transaction for an index path in the history view controller.

Ryan Olson 11 lat temu
rodzic
commit
11411a20b7

+ 12 - 7
Classes/Network/FLEXNetworkHistoryTableViewController.m

@@ -95,13 +95,7 @@
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     FLEXNetworkTransactionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kFLEXNetworkTransactionCellIdentifier forIndexPath:indexPath];
-    FLEXNetworkTransaction *transaction = nil;
-    if (tableView == self.tableView) {
-        transaction = [self.networkTransactions objectAtIndex:indexPath.row];
-    } else if (tableView == self.searchController.searchResultsTableView) {
-        transaction = [self.filteredNetworkTransactions objectAtIndex:indexPath.row];
-    }
-    cell.transaction = transaction;
+    cell.transaction = [self transactionAtIndexPath:indexPath inTableView:tableView];
 
     if (indexPath.row % 2 == 0) {
         cell.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
@@ -112,6 +106,17 @@
     return cell;
 }
 
+- (FLEXNetworkTransaction *)transactionAtIndexPath:(NSIndexPath *)indexPath inTableView:(UITableView *)tableView
+{
+    FLEXNetworkTransaction *transaction = nil;
+    if (tableView == self.tableView) {
+        transaction = [self.networkTransactions objectAtIndex:indexPath.row];
+    } else if (tableView == self.searchController.searchResultsTableView) {
+        transaction = [self.filteredNetworkTransactions objectAtIndex:indexPath.row];
+    }
+    return transaction;
+}
+
 #pragma mark - Search display delegate
 
 - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString