Latest 0.0.4
Homepage https://github.com/Haisens/HCRouterKit
License MIT
Platforms ios 8.0
Dependencies HCFoundation
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

HCRouterKit is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'HCRouterKit'

1、路由注册,项目中的路由注册统一写在一个类中(NSObject或其他),相当于hosts文件,然后把需要在模块之外被调用的类以及方法注册在里面。进而进行界面跳转和方法调用。

static NSString *ROUTER_SCHEME = @"hcrouterkit";
#import "HCTestRouter.h"
#import "HCRouterKit.h"
#import "HCViewController.h"
//注册路由scheme
[[HCRouterKit defaultRouter] registerRouterWithScheme:ROUTER_SCHEME];
//注册类名以及快捷类名
[[HCRouterKit defaultRouter] registerClassQuickName:@"testhost" className:NSStringFromClass([self class])];
//注册方法名以及快捷方法名
[[HCRouterKit defaultRouter] registerSelectorQuickName:@"getvc" selectorName:@"getController:"];

2、在注册路由的类中实现获取实力对象及方法调用的方法


- (UIViewController *)getController:(NSDictionary *)parameters {
    return [[HCViewController alloc] initWithColor:parameters];
}

3、在HCViewController中

- (instancetype)initWithColor:(NSDictionary *)colorDic {
    if (self = [super init]) {
        self.view.backgroundColor = colorDic[@"color"];
    }
    return self;
}
BlockSelf(blockSelf);
[[HCRouterKit defaultRouter] openURL:@"hcrouterkit://testhost/getvc" parameters:@{@"color":[UIColor yellowColor]} completion:^(id  _Nullable completionObject) {

    if ([completionObject isKindOfClass:[UIViewController class]]) {
        [blockSelf presentViewController:completionObject animated:YES completion:^{
            NSLog(@"n跳转成功!n");
        }];
    }

} finished:^(id  _Nullable finishedObject) {

    NSLog(@"我是finished回调的:%@", finishedObject);

}];

4、注意:如果是有finished回调的,需在被访问的控制器(上述中的HCViewController)中遵循HCRouterKit的协议,并实现回调方法。

[self hcrouter_performFinishedBlock:@"我是finished回调"];

Author

[email protected], 殷海超(Groot)

License

HCRouterKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "HCRouterKit",
    "version": "0.0.4",
    "summary": "u7b80u5355u6613u7528u7684u8defu7531u7ec4u4ef6.",
    "description": "TODO: u7c7bu4e4bu95f4u65e0u9700#importu5373u53efu5b9eu73b0u8df3u8f6cuff0cu65b9u6cd5u8c03u7528u3002u51cfu5c11u4ee3u7801u8026u5408u6027u3002u56e2u961fu5f00u53d1u795eu5668.",
    "homepage": "https://github.com/Haisens/HCRouterKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u6bb7u6d77u8d85,Groot": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Haisens/HCRouterKit.git",
        "tag": "0.0.4"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "HCRouterKit/*.{h,m}",
    "public_header_files": "HCRouterKit/HCRouterKit.h",
    "dependencies": {
        "HCFoundation": []
    }
}

Pin It on Pinterest

Share This