Skip to content

Instantly share code, notes, and snippets.

@dopcn
Last active August 29, 2015 14:24
Show Gist options
  • Save dopcn/d87ac4aaeb73d1309bde to your computer and use it in GitHub Desktop.
Save dopcn/d87ac4aaeb73d1309bde to your computer and use it in GitHub Desktop.
based on control vs based on data
//based on control
//===============================================================================================================
- (void)iPhoneHandleOpenURL:(NSURL *)url {
NSString *keyword = url.host;
if ([keyword isEqualToString:@"feed"]) {
//
} else if ([keyword isEqualToString:@"board"]) {
//
} else if ([keyword isEqualToString:@"threads"]) {
//
} else if ([keyword isEqualToString:@"home"]) {
//
} else if ([keyword isEqualToString:@"money"]) {
//
} else if ([keyword isEqualToString:@"user"]) {
//
} else if ([keyword isEqualToString:@"post"]) {
//
} else if ([keyword isEqualToString:@"specialtopic"]) {
//
}
}
//based on data
//===============================================================================================================
- (void)iPhoneHandleDXYOpenURL:(NSURL *)url {
NSDictionary *keyword2handler =
@{@"pubaccount":^(){
//
},@"board":^(){
//
},@"threads":^(){
//
},@"home":^(){
//
},@"money":^(){
//
},@"user":^(){
//
},@"feed":^(){
//
},@"post":^(){
//
}};
NSString *keyword = url.host;
if (keyword2handler[keyword] != nil) {
void(^handler)(void) = keyword2handler[keyword];
handler();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment