4
4
//
5
5
// Created by Ullrich Schäfer on 07.10.09.
6
6
//
7
- // Copyright 2010 nxtbgthng. All rights reserved.
7
+ // Copyright 2010 nxtbgthng. All rights reserved.
8
8
//
9
9
// Licenced under the new BSD-licence.
10
- // See README.md in this repository for
10
+ // See README.md in this repository for
11
11
// the full licence.
12
12
//
13
13
@@ -19,7 +19,7 @@ @implementation NSString (NXOAuth2)
19
19
+ (NSString *)nxoauth2_stringWithUUID ;
20
20
{
21
21
__autoreleasing NSString *result;
22
- CFUUIDRef theUUID = CFUUIDCreate (kCFAllocatorDefault );
22
+ CFUUIDRef theUUID = CFUUIDCreate (kCFAllocatorDefault );
23
23
result = (__bridge_transfer NSString *)CFUUIDCreateString (kCFAllocatorDefault , theUUID);
24
24
CFRelease (theUUID);
25
25
return result;
@@ -30,28 +30,28 @@ + (NSString *)nxoauth2_stringWithUUID;
30
30
31
31
+ (NSString *)nxoauth2_stringWithEncodedQueryParameters : (NSDictionary *)parameters ;
32
32
{
33
-
34
- NSMutableArray *parameterPairs = [NSMutableArray array ];
35
- for (NSString *key in [parameters allKeys ]) {
36
- NSString *pair = [NSString stringWithFormat: @" %@ =%@ " , [key nxoauth2_URLEncodedString ], [[parameters objectForKey: key] nxoauth2_URLEncodedString ]];
37
- [parameterPairs addObject: pair];
38
- }
39
- return [parameterPairs componentsJoinedByString: @" &" ];
33
+
34
+ NSMutableArray *parameterPairs = [NSMutableArray array ];
35
+ for (NSString *key in [parameters allKeys ]) {
36
+ NSString *pair = [NSString stringWithFormat: @" %@ =%@ " , [key nxoauth2_URLEncodedString ], [[parameters objectForKey: key] nxoauth2_URLEncodedString ]];
37
+ [parameterPairs addObject: pair];
38
+ }
39
+ return [parameterPairs componentsJoinedByString: @" &" ];
40
40
}
41
41
42
42
- (NSDictionary *)nxoauth2_parametersFromEncodedQueryString ;
43
43
{
44
- NSArray *encodedParameterPairs = [self componentsSeparatedByString: @" &" ];
44
+ NSArray *encodedParameterPairs = [self componentsSeparatedByString: @" &" ];
45
45
NSMutableDictionary *requestParameters = [NSMutableDictionary dictionary ];
46
46
47
47
for (NSString *encodedPair in encodedParameterPairs) {
48
48
NSArray *encodedPairElements = [encodedPair componentsSeparatedByString: @" =" ];
49
- if (encodedPairElements.count == 2 ) {
50
- [requestParameters setValue: [[encodedPairElements objectAtIndex: 1 ] nxoauth2_URLDecodedString ]
51
- forKey: [[encodedPairElements objectAtIndex: 0 ] nxoauth2_URLDecodedString ]];
52
- }
49
+ if (encodedPairElements.count == 2 ) {
50
+ [requestParameters setValue: [[encodedPairElements objectAtIndex: 1 ] nxoauth2_URLDecodedString ]
51
+ forKey: [[encodedPairElements objectAtIndex: 0 ] nxoauth2_URLDecodedString ]];
52
+ }
53
53
}
54
- return requestParameters;
54
+ return requestParameters;
55
55
}
56
56
57
57
@@ -60,13 +60,13 @@ - (NSDictionary *)nxoauth2_parametersFromEncodedQueryString;
60
60
- (NSString *)nxoauth2_URLEncodedString ;
61
61
{
62
62
63
- CFStringRef cfResult = CFURLCreateStringByAddingPercentEscapes (kCFAllocatorDefault , // Allocator
63
+ CFStringRef cfResult = CFURLCreateStringByAddingPercentEscapes (kCFAllocatorDefault , // Allocator
64
64
(__bridge CFStringRef )self, // Original String
65
65
NULL , // Characters to leave unescaped
66
66
(CFStringRef )@" !*'();:@&=+$,/?%#[]" , // Legal Characters to be escaped
67
67
kCFStringEncodingUTF8 ); // Encoding
68
68
__autoreleasing NSString *result = (__bridge_transfer NSString *)cfResult;
69
- return result;
69
+ return result;
70
70
}
71
71
72
72
- (NSString *)nxoauth2_URLDecodedString ;
@@ -76,7 +76,7 @@ - (NSString *)nxoauth2_URLDecodedString;
76
76
CFSTR (" " ),
77
77
kCFStringEncodingUTF8 );
78
78
__autoreleasing NSString *result = (__bridge_transfer NSString *)cfResult;
79
- return result;
79
+ return result;
80
80
}
81
81
82
82
@end
0 commit comments