Преглед на файлове

Add copy button to request detail view controller.

Copies the text contents of all the rows (i.e. general, request headers, response headers, query parameters, etc.)
Ryan Olson преди 11 години
родител
ревизия
f590263d9f
променени са 1 файла, в които са добавени 25 реда и са изтрити 0 реда
  1. 25 0
      Classes/Network/FLEXNetworkTransactionDetailTableViewController.m

+ 25 - 0
Classes/Network/FLEXNetworkTransactionDetailTableViewController.m

@@ -53,6 +53,7 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
     self = [super initWithStyle:UITableViewStyleGrouped];
     if (self) {
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTransactionUpdatedNotification:) name:kFLEXNetworkRecorderTransactionUpdatedNotification object:nil];
+        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Copy" style:UIBarButtonItemStylePlain target:self action:@selector(copyButtonPressed:)];
     }
     return self;
 }
@@ -117,6 +118,30 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
     }
 }
 
+- (void)copyButtonPressed:(id)sender
+{
+    NSMutableString *requestDetailString = [NSMutableString string];
+
+    for (FLEXNetworkDetailSection *section in self.sections) {
+        if ([section.rows count] > 0) {
+            if ([section.title length] > 0) {
+                [requestDetailString appendString:section.title];
+                [requestDetailString appendString:@"\n\n"];
+            }
+            for (FLEXNetworkDetailRow *row in section.rows) {
+                NSString *rowDescription = [[[self class] attributedTextForRow:row] string];
+                if ([rowDescription length] > 0) {
+                    [requestDetailString appendString:rowDescription];
+                    [requestDetailString appendString:@"\n"];
+                }
+            }
+            [requestDetailString appendString:@"\n\n"];
+        }
+    }
+
+    [[UIPasteboard generalPasteboard] setString:requestDetailString];
+}
+
 #pragma mark - Table view data source
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView