Permalink
Browse files

Merge pull request #13 from betamike/master

Removed 4.0+ Method Call in OAMutableURLRequest
  • Loading branch information...
2 parents f7e947e + 2efd04c commit b6fa84acdda96f1231dda38350a2cd521a24e12c @jdg committed Sep 6, 2011
Showing with 22 additions and 18 deletions.
  1. +22 −18 OAMutableURLRequest.m
View
@@ -138,6 +138,26 @@ - (void)_generateNonce {
nonce = (NSString *)string;
}
+NSInteger normalize(id obj1, id obj2, void *context)
+{
+ NSArray *nameAndValue1 = [obj1 componentsSeparatedByString:@"="];
+ NSArray *nameAndValue2 = [obj2 componentsSeparatedByString:@"="];
+
+ NSString *name1 = [nameAndValue1 objectAtIndex:0];
+ NSString *name2 = [nameAndValue2 objectAtIndex:0];
+
+ NSComparisonResult comparisonResult = [name1 compare:name2];
+ if (comparisonResult == NSOrderedSame) {
+ NSString *value1 = [nameAndValue1 objectAtIndex:1];
+ NSString *value2 = [nameAndValue2 objectAtIndex:1];
+
+ comparisonResult = [value1 compare:value2];
+ }
+
+ return comparisonResult;
+}
+
+
- (NSString *)_signatureBaseString {
// OAuth Spec, Section 9.1.1 "Normalize Request Parameters"
// build a sorted array of both request parameters and OAuth header parameters
@@ -174,24 +194,8 @@ - (NSString *)_signatureBaseString {
}
}
- // Oauth Spec, Section 3.4.1.3.2 "Parameters Normalization"
- NSArray *sortedPairs = [parameterPairs sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
- NSArray *nameAndValue1 = [obj1 componentsSeparatedByString:@"="];
- NSArray *nameAndValue2 = [obj2 componentsSeparatedByString:@"="];
-
- NSString *name1 = [nameAndValue1 objectAtIndex:0];
- NSString *name2 = [nameAndValue2 objectAtIndex:0];
-
- NSComparisonResult comparisonResult = [name1 compare:name2];
- if (comparisonResult == NSOrderedSame) {
- NSString *value1 = [nameAndValue1 objectAtIndex:1];
- NSString *value2 = [nameAndValue2 objectAtIndex:1];
-
- comparisonResult = [value1 compare:value2];
- }
-
- return comparisonResult;
- }];
+ // Oauth Spec, Section 3.4.1.3.2 "Parameters Normalization
+ NSArray *sortedPairs = [parameterPairs sortedArrayUsingFunction:normalize context:NULL];
NSString *normalizedRequestParameters = [sortedPairs componentsJoinedByString:@"&"];
[parameterPairs release];

0 comments on commit b6fa84a

Please sign in to comment.