Latest 1.0.1
Homepage https://github.com/Liya86/LYRouter
License MIT
Platforms ios 8.0, requires ARC
Frameworks Foundation, UIKit

模块化开发通信中间层封装

  • 引入:
    pod ‘LYRouter’

  • 使用
    设置默认协议、合法域名
  [LYRouter setDefaultScheme:@"liya"];
  [[LYRouter shareManager] addSchemes:@[@"edward"]];

注册协议

[[LYRouter shareManager] addToPath:@"keaiduo/nslog" withRegisterActionBlock:^(LYURIRequest *action) {
        NSString *warning = action.uri.query[@"warning"];
        NSLog(@"LYTestObject warning = %@", warning);
    }];
[[LYRouter shareManager] addToPath:@"keaiduo/multiplication" withRegisterActionBlock:^(LYURIRequest *action) {
        NSInteger multiplier = [action.uri.query[@"multiplier"] integerValue];
        NSInteger multiplicand = [action.uri.query[@"multiplicand"] integerValue];
        NSInteger product = multiplier * multiplicand;
        //数据回传
        [action callbackWithObject:@(product)];
    }];

协议调用

[[LYRouter shareManager] runWithPath:@"keaiduo/nslog"
                                         query:@{@"warning":@"可爱多 🐶"}
                                     completed:nil];

LYURIRequest *uriRequest = [LYURIRequest requestWithURI:[LYURI URIWithPath:@"keaiduo/multiplication"
                                                                         query:@{@"multiplier":@5, @"multiplicand":@6}]
                                               dataCallback:^id(id result, NSError *error) {
                                                   NSLog(@"LYTestObject test product = %@", result);
                                                   return nil;
                                                                                                 }];
[[LYRouter shareManager] runWithURIRequest:uriRequest];

Latest podspec

{
    "name": "LYRouter",
    "version": "1.0.1",
    "summary": "u6a21u5757u5f00u53d1u4e2du95f4u5c42u7684u5c01u88c5",
    "description": "u6a21u5757u5f00u53d1u4e2du95f4u5c42u7684u5c01u88c5 ^-^",
    "homepage": "https://github.com/Liya86/LYRouter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "Liya86",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/Liya86/LYRouter.git",
        "tag": "1.0.1"
    },
    "source_files": "Source/**/*.{h,m}",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This