Skip to content
Browse files

prefix category methods

  • Loading branch information...
1 parent b4d36ed commit b3babeb7050eeb968629bb8ae969005a1390653c @toco committed Feb 26, 2014
View
6 XNGOAuth1Client/NSDictionary+XNGOAuth1Additions.h
@@ -1,9 +1,9 @@
@interface NSDictionary (XNGOAuth1Additions)
-+ (id)dictionaryFromQueryString:(NSString *)queryString;
++ (id)xngo_dictionaryFromQueryString:(NSString *)queryString;
-- (id)initWithQueryString:(NSString *)queryString;
+- (id)xngo_initWithQueryString:(NSString *)queryString;
-- (NSString *)queryStringRepresentation;
+- (NSString *)xngo_queryStringRepresentation;
@end
View
14 XNGOAuth1Client/NSDictionary+XNGOAuth1Additions.m
@@ -3,29 +3,29 @@
@implementation NSDictionary (XNGOAuth1Additions)
-+ (id)dictionaryFromQueryString:(NSString *)queryString {
- return [[NSDictionary alloc] initWithQueryString:queryString];
++ (id)xngo_dictionaryFromQueryString:(NSString *)queryString {
+ return [[NSDictionary alloc] xngo_initWithQueryString:queryString];
}
-- (id)initWithQueryString:(NSString *)queryString {
+- (id)xngo_initWithQueryString:(NSString *)queryString {
NSArray *components = [queryString componentsSeparatedByString:@"&"];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (NSString *component in components) {
NSArray *keyValue = [component componentsSeparatedByString:@"="];
- NSString *key = [keyValue[0] URLDecode];
- NSString *value = [keyValue[1] URLDecode];
+ NSString *key = [keyValue[0] xngo_URLDecode];
+ NSString *value = [keyValue[1] xngo_URLDecode];
[dictionary setObject:value forKey:key];
}
return dictionary;
}
-- (NSString *)queryStringRepresentation {
+- (NSString *)xngo_queryStringRepresentation {
NSMutableArray *paramArray = [NSMutableArray array];
[self enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
- NSString *param = [NSString stringWithFormat:@"%@=%@", [key URLEncode], [value URLEncode]];
+ NSString *param = [NSString stringWithFormat:@"%@=%@", [key xngo_URLEncode], [value xngo_URLEncode]];
[paramArray addObject:param];
}];
View
4 XNGOAuth1Client/NSString+XNGOAuth1Additions.h
@@ -1,7 +1,7 @@
@interface NSString (XNGOAuth1Additions)
-- (NSString *)URLEncode;
+- (NSString *)xngo_URLEncode;
-- (NSString *)URLDecode;
+- (NSString *)xngo_URLDecode;
@end
View
4 XNGOAuth1Client/NSString+XNGOAuth1Additions.m
@@ -2,7 +2,7 @@
@implementation NSString (XNGOAuth1Additions)
-- (NSString *)URLEncode {
+- (NSString *)xngo_URLEncode {
return (__bridge_transfer NSString *)
CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(__bridge CFStringRef)self,
@@ -11,7 +11,7 @@ - (NSString *)URLEncode {
kCFStringEncodingUTF8);
}
-- (NSString *)URLDecode {
+- (NSString *)xngo_URLDecode {
return (__bridge_transfer NSString *)
CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
(__bridge CFStringRef)self,
View
2 XNGOAuth1Client/XNGOAuthToken.m
@@ -27,7 +27,7 @@ - (id)initWithQueryString:(NSString *)queryString {
return nil;
}
- NSDictionary *attributes = [NSDictionary dictionaryFromQueryString:queryString];
+ NSDictionary *attributes = [NSDictionary xngo_dictionaryFromQueryString:queryString];
if (attributes.allKeys.count == 0) {
return nil;
View
8 XNGOAuth1ClientTests/NSDictionaryAdditionsTests.m
@@ -12,15 +12,15 @@ @implementation NSDictionaryAdditionsTests
- (void)testInitializer {
NSString *queryString = @"param1=HELLO&param2=XING";
- NSDictionary *resultDict = [[NSDictionary alloc] initWithQueryString:queryString];
+ NSDictionary *resultDict = [[NSDictionary alloc] xngo_initWithQueryString:queryString];
expect(resultDict[@"param1"]).to.equal(@"HELLO");
expect(resultDict[@"param2"]).to.equal(@"XING");
}
- (void)testClassMethod {
NSString *queryString = @"param1=HELLO&param2=XING";
- NSDictionary *resultDict = [NSDictionary dictionaryFromQueryString:queryString];
+ NSDictionary *resultDict = [NSDictionary xngo_dictionaryFromQueryString:queryString];
expect(resultDict[@"param1"]).to.equal(@"HELLO");
expect(resultDict[@"param2"]).to.equal(@"XING");
@@ -29,8 +29,8 @@ - (void)testClassMethod {
- (void)testQueryStringRepresentation {
NSDictionary *dictionary = @{
@"param1": @"HELLO",
- @"param2":@"XING"};
- NSString *queryString = [dictionary queryStringRepresentation];
+ @"param2": @"XING"};
+ NSString *queryString = [dictionary xngo_queryStringRepresentation];
expect(queryString).to.equal(@"param1=HELLO&param2=XING");
}

0 comments on commit b3babeb

Please sign in to comment.
Something went wrong with that request. Please try again.