Procházet zdrojové kódy

Generalize utility method to generate dictionary from query data

We’ll use it for post bodies with application/x-www-form-urlencoded content types.
Ryan Olson před 11 roky
rodič
revize
73f3d52bb3

+ 1 - 1
Classes/Network/FLEXNetworkTransactionDetailTableViewController.m

@@ -316,7 +316,7 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
 
 + (FLEXNetworkDetailSection *)queryParametersSectionForTransaction:(FLEXNetworkTransaction *)transaction
 {
-    NSDictionary *queryDictionary = [FLEXUtility queryDictionaryFromURL:transaction.request.URL];
+    NSDictionary *queryDictionary = [FLEXUtility dictionaryFromQuery:transaction.request.URL.query];
     FLEXNetworkDetailSection *querySection = [[FLEXNetworkDetailSection alloc] init];
     querySection.title = @"Query Parameters";
     querySection.rows = [self networkDetailRowsFromDictionary:queryDictionary];

+ 1 - 1
Classes/Utility/FLEXUtility.h

@@ -33,7 +33,7 @@
 + (UIImage *)thumbnailedImageWithMaxPixelDimension:(NSInteger)dimension fromImageData:(NSData *)data;
 + (NSString *)stringFromRequestDuration:(NSTimeInterval)duration;
 + (NSString *)statusCodeStringFromURLResponse:(NSURLResponse *)response;
-+ (NSDictionary *)queryDictionaryFromURL:(NSURL *)url;
++ (NSDictionary *)dictionaryFromQuery:(NSString *)query;
 + (NSString *)prettyJSONStringFromData:(NSData *)data;
 
 @end

+ 2 - 2
Classes/Utility/FLEXUtility.m

@@ -235,12 +235,12 @@
     return httpResponseString;
 }
 
-+ (NSDictionary *)queryDictionaryFromURL:(NSURL *)url
++ (NSDictionary *)dictionaryFromQuery:(NSString *)query
 {
     NSMutableDictionary *queryDictionary = [NSMutableDictionary dictionary];
 
     // [a=1, b=2, c=3]
-    NSArray *queryComponents = [url.query componentsSeparatedByString:@"&"];
+    NSArray *queryComponents = [query componentsSeparatedByString:@"&"];
     for (NSString *keyValueString in queryComponents) {
         // [a, 1]
         NSArray *components = [keyValueString componentsSeparatedByString:@"="];