Created
September 11, 2012 08:30
-
-
Save yiyuanlu/3696897 to your computer and use it in GitHub Desktop.
Params
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
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { | |
NSLog(@"application:openURL: --- %@", url); | |
if([[url scheme] isEqualToString: [NSString stringWithFormat:@"sz%@", SSZ_APPLICATION_ID]]) | |
{ | |
NSString* entityKey = [[[url queryDictionary] objectForKey:@"url"]stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; | |
if(entityKey) | |
{ | |
[Socialize entityLoaderBlock](nil, [SZEntity entityWithKey:entityKey]); | |
} | |
} | |
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
#import <Foundation/Foundation.h> | |
@interface NSURL (Params) | |
-(NSDictionary*) queryDictionary; | |
@end |
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
#import "NSURL+Params.h" | |
@implementation NSURL (Params) | |
-(NSDictionary*) queryDictionary | |
{ | |
NSArray *parameters = [[self query] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"=&"]]; | |
NSMutableDictionary *keyValueParm = [NSMutableDictionary dictionary]; | |
for (int i = 0; i < [parameters count]; i=i+2) { | |
[keyValueParm setObject:[parameters objectAtIndex:i+1] forKey:[parameters objectAtIndex:i]]; | |
} | |
return keyValueParm; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment