Просмотр исходного кода

Make use of new request related FLEXUtility methods

Ryan Olson лет назад: 11
Родитель
Сommit
34721971c5

+ 1 - 3
Classes/Global State Explorers/FLEXFileBrowserTableViewController.m

@@ -237,9 +237,7 @@
             if ([[subpath pathExtension] isEqual:@"archive"]) {
                 prettyString = [[NSKeyedUnarchiver unarchiveObjectWithFile:fullPath] description];
             } else if ([[subpath pathExtension] isEqualToString:@"json"]) {
-                NSData *fileData = [NSData dataWithContentsOfFile:fullPath];
-                id jsonObject = [NSJSONSerialization JSONObjectWithData:fileData options:0 error:NULL];
-                prettyString = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:jsonObject options:NSJSONWritingPrettyPrinted error:NULL] encoding:NSUTF8StringEncoding];
+                prettyString = [FLEXUtility prettyJSONStringFromData:[NSData dataWithContentsOfFile:fullPath]];
             } else if ([[subpath pathExtension] isEqualToString:@"plist"]) {
                 NSData *fileData = [NSData dataWithContentsOfFile:fullPath];
                 prettyString = [[NSPropertyListSerialization propertyListWithData:fileData options:0 format:NULL error:NULL] description];

+ 3 - 11
Classes/Network/FLEXNetworkTransactionTableViewCell.m

@@ -133,17 +133,9 @@ NSString *const kFLEXNetworkTransactionCellIdentifier = @"kFLEXNetworkTransactio
     }
 
     if (self.transaction.transactionState == FLEXNetworkTransactionStateFinished || self.transaction.transactionState == FLEXNetworkTransactionStateFailed) {
-        if ([self.transaction.response isKindOfClass:[NSHTTPURLResponse class]]) {
-            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)self.transaction.response;
-            NSString *statusCodeDescription = nil;
-            if (httpResponse.statusCode == 200) {
-                // Prefer OK to the default "no error"
-                statusCodeDescription = @"OK";
-            } else {
-                statusCodeDescription = [NSHTTPURLResponse localizedStringForStatusCode:httpResponse.statusCode];
-            }
-            NSString *httpResponseString = [NSString stringWithFormat:@"%ld %@", (long)httpResponse.statusCode, statusCodeDescription];
-            [detailComponents addObject:httpResponseString];
+        NSString *statusCodeString = [FLEXUtility statusCodeStringFromURLResponse:self.transaction.response];
+        if ([statusCodeString length] > 0) {
+            [detailComponents addObject:statusCodeString];
         }
 
         if (self.transaction.receivedDataLength > 0) {