Created
November 26, 2013 16:05
-
-
Save degt/7661006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSMutableDictionary+Utilities.h | |
// | |
// Created by Daniel Gutierrez on 11/26/13. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSMutableDictionary (Utilities) | |
- (NSMutableDictionary *) dictionaryWithQueryString: (NSString *) queryString; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSMutableDictionary+Utilities.m | |
// | |
// Created by Daniel Gutierrez on 11/26/13. | |
// | |
#import "NSMutableDictionary+Utilities.h" | |
@implementation NSMutableDictionary (Utilities) | |
- (NSMutableDictionary *) dictionaryWithQueryString: (NSString *) queryString{ | |
//Parse URL | |
NSMutableDictionary *queryStringDictionary = [[NSMutableDictionary alloc] init]; | |
NSArray *urlComponents = [queryString componentsSeparatedByString:@"&"]; | |
for (NSString *keyValuePair in urlComponents) | |
{ | |
NSArray *pairComponents = [keyValuePair componentsSeparatedByString:@"="]; | |
NSString *key = [pairComponents objectAtIndex:0]; | |
NSString *value = [pairComponents objectAtIndex:1]; | |
[queryStringDictionary setObject:value forKey:key]; | |
} | |
return queryStringDictionary; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment