一个用于 iOS 模块和组件分离的解决方案。您可以使用 URL 路由到 viewController 或执行原生 block。
[JWIntentContext registerRouterClass:"LoginViewController"
forKey:@"login"];
[JWIntentContext registerHandler:^(NSDictionary *param) {
NSLog(@"%@", param[@"message"]);
}
forKey:@"testAlert"];
JWRouter *intent = [[JWRouter alloc] initWithSource:self
routerKey:@"login"];
[intent submit];
JWIntent *intent = [JWIntent intentWithURLString:@"router://login?extraData={\"username\":\"jerry\"}"
context:nil];
[intent submit];
JWIntent *intent = [JWIntent intentWithURLString:@"handler://testAlert?extraData={\"title\":\"Hello Alert\",\"message\":\"I have a message for you.\"}"
context:nil];
[intent submit];
要使用 CocoaPods 将 JWIntent 集成到您的 Xcode 项目中,在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
pod 'JWIntent'
然后,运行以下命令:
$ pod install
(MIT 许可证)