Skip to content
This repository

Removed 4.0+ Method Call in OAMutableURLRequest #13

Merged
merged 1 commit into from over 2 years ago

2 participants

Mike Cugini Jonathan George
Mike Cugini

Replaced the parameter sorting method with one compatible with 3.0+.

Jonathan George jdg merged commit b6fa84a into from September 05, 2011
Jonathan George jdg closed this September 05, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 16, 2011
Mike Cugini moved sorting comparison in OAMutableURLRequest to use a 3.x compatib…
…le method
2efd04c
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 22 additions and 18 deletions. Show diff stats Hide diff stats

  1. 40  OAMutableURLRequest.m
40  OAMutableURLRequest.m
@@ -142,6 +142,26 @@ - (void)_generateNonce {
142 142
     nonce = (NSString *)string;
143 143
 }
144 144
 
  145
+NSInteger normalize(id obj1, id obj2, void *context)
  146
+{
  147
+    NSArray *nameAndValue1 = [obj1 componentsSeparatedByString:@"="];
  148
+    NSArray *nameAndValue2 = [obj2 componentsSeparatedByString:@"="];
  149
+    
  150
+    NSString *name1 = [nameAndValue1 objectAtIndex:0];
  151
+    NSString *name2 = [nameAndValue2 objectAtIndex:0];
  152
+    
  153
+    NSComparisonResult comparisonResult = [name1 compare:name2];
  154
+    if (comparisonResult == NSOrderedSame) {
  155
+        NSString *value1 = [nameAndValue1 objectAtIndex:1];
  156
+        NSString *value2 = [nameAndValue2 objectAtIndex:1];
  157
+        
  158
+        comparisonResult = [value1 compare:value2];
  159
+    }
  160
+    
  161
+    return comparisonResult;
  162
+}
  163
+
  164
+
145 165
 - (NSString *)_signatureBaseString {
146 166
     // OAuth Spec, Section 9.1.1 "Normalize Request Parameters"
147 167
     // build a sorted array of both request parameters and OAuth header parameters
@@ -178,24 +198,8 @@ - (NSString *)_signatureBaseString {
178 198
 		}
179 199
 	}
180 200
     
181  
-    // Oauth Spec, Section 3.4.1.3.2 "Parameters Normalization"
182  
-    NSArray *sortedPairs = [parameterPairs sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
183  
-        NSArray *nameAndValue1 = [obj1 componentsSeparatedByString:@"="];
184  
-        NSArray *nameAndValue2 = [obj2 componentsSeparatedByString:@"="];
185  
-        
186  
-        NSString *name1 = [nameAndValue1 objectAtIndex:0];
187  
-        NSString *name2 = [nameAndValue2 objectAtIndex:0];
188  
-        
189  
-        NSComparisonResult comparisonResult = [name1 compare:name2];
190  
-        if (comparisonResult == NSOrderedSame) {
191  
-            NSString *value1 = [nameAndValue1 objectAtIndex:1];
192  
-            NSString *value2 = [nameAndValue2 objectAtIndex:1];
193  
-
194  
-            comparisonResult = [value1 compare:value2];
195  
-        }
196  
-        
197  
-        return comparisonResult;
198  
-    }];
  201
+    // Oauth Spec, Section 3.4.1.3.2 "Parameters Normalization    
  202
+    NSArray *sortedPairs = [parameterPairs sortedArrayUsingFunction:normalize context:NULL];
199 203
 
200 204
     NSString *normalizedRequestParameters = [sortedPairs componentsJoinedByString:@"&"];
201 205
     [parameterPairs release];
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.