Created
November 11, 2013 04:39
-
-
Save paingpyi/7407947 to your computer and use it in GitHub Desktop.
This file contains 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
+ (NSDictionary*)getParamFromURL:(NSString*)str | |
{ | |
NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; | |
NSString *url=str; | |
NSArray *comp1 = [url componentsSeparatedByString:@"?"]; | |
NSString *query = [comp1 lastObject]; | |
NSArray *queryElements = [query componentsSeparatedByString:@"&"]; | |
for (NSString *element in queryElements) { | |
NSArray *keyVal = [element componentsSeparatedByString:@"="]; | |
if (keyVal.count > 0) { | |
NSString *variableKey = [keyVal objectAtIndex:0]; | |
NSString *value = (keyVal.count == 2) ? [keyVal lastObject] : nil; | |
NSLog(@"%@ -> %@",variableKey,value); | |
[params setValue:value forKey:variableKey]; | |
} | |
} | |
return [params copy]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment