要运行示例项目,请克隆仓库,并首先从 Example 目录中运行 pod install
。
DTRouter 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile:
pod "DTRouter"
or 'DTRouter/Core'
or 'DTRouter/UI'
//regist
-(void)addRouter:(NSString *)URLPattern handler:(DTRouterRegistHandler)handler;
//route
-(DTRouterResponse *)route:(NSString *)URLString arguments:(NSDictionary *)arguments;
-(NSOperation *)asyncRoute:(NSString *)URLString arguments:(NSDictionary *)arguments handler:(DTResponseBlock)handler;
//regist
[[DTRouterService sharedInstance]addRouter:@"addnumber/:num" handler:^id(NSDictionary *paths, NSDictionary *arguments) {
NSString * num = paths[@"num"];
handler handle = arguments[@"taskkey"];
return nil;
}];
//route
handler h = ^(long long num){
NSLog(@"current num : %lld",num);
};
[[DTRouterService sharedInstance]asyncRoute:@"addnumber/100" arguments:@{@"taskkey":h} handler:^(DTRouterResponse *response) {
NSLog(@"result : %@",response.resultValue);
}];
DTRouter 在 MIT 许可证下可用。查看 LICENSE 文件获取更多信息。