Last active
August 29, 2015 14:24
-
-
Save dopcn/d87ac4aaeb73d1309bde to your computer and use it in GitHub Desktop.
based on control vs based on data
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
//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