Last active
August 29, 2015 14:13
-
-
Save AlexHedley/3eb964d2e1a0a77690e9 to your computer and use it in GitHub Desktop.
Custom URL Scheme
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
| - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { | |
| NSLog(@"url recieved: %@", url); | |
| NSLog(@"query string: %@", [url query]); | |
| NSLog(@"host: %@", [url host]); | |
| NSLog(@"url path: %@", [url path]); | |
| NSDictionary *dict = [self parseQueryString:[url query]]; | |
| NSLog(@"query dict: %@", dict); | |
| return YES; | |
| } |
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
| //http://www.idev101.com/code/Objective-C/custom_url_schemes.html | |
| - (NSDictionary *)parseQueryString:(NSString *)query { | |
| NSMutableDictionary *dict = [[[NSMutableDictionary alloc] initWithCapacity:6] autorelease]; | |
| NSArray *pairs = [query componentsSeparatedByString:@"&"]; | |
| for (NSString *pair in pairs) { | |
| NSArray *elements = [pair componentsSeparatedByString:@"="]; | |
| NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
| NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
| [dict setObject:val forKey:key]; | |
| } | |
| return dict; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment