Latest 0.0.2
Homepage https://github.com/duanruiying/DryInterRouter
License MIT
Platforms ios 10.0, requires ARC
Frameworks UIKit, Foundation
Authors

iOS: iOS: Swift内部独立路由,用于解耦视图控制器之间的push

Prerequisites

  • Xcode 10.2.1
  • iOS 9.0 or later
  • ObjC、Swift 5 or later

Installation

  • pod ‘DryInterRouter’

Features – 常用方法

  1. 设置导航实现的协议实例
    DryInterRouter.default.setupImplement(InterRouterNavImplement())
  2. 导航协议实现实例
    
    //MARK: - 申明视图控制器
    enum InterRouterNav: DryInterRouterNav {
    /// ViewController1
    case vc1
    /// ViewController2
    case vc2(String?)
    /// ViewController2
    case vc3(String?, Int?)
    }

//MARK: – 导航协议实现
class InterRouterNavImplement: DryInterRouterNavImplement {

/// 获取视图控制器
func viewController(_ nav: DryInterRouterNav) -> UIViewController {

    guard let navigation = nav as? InterRouterNav else {
        return UIViewController()
    }

    switch navigation {
    case .vc1: return ViewController1()
    case .vc2(let p1): return ViewController2.init(param1: p1)
    case .vc3(let p1, let p2): return ViewController2 .init(param1: p1, param2: p2)
    }
}

/// Push
func push(_ nav: DryInterRouterNav, from: UIViewController, to: UIViewController) {
    from.navigationController?.pushViewController(to, animated: true)
}

}

3. 调用

self.dry_interRouter_push(InterRouterNav.vc2("1"))

Latest podspec

{
    "name": "DryInterRouter",
    "version": "0.0.2",
    "summary": "DryInterRouter",
    "homepage": "https://github.com/duanruiying/DryInterRouter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "duanruiying": "[email protected]"
    },
    "source": {
        "git": "https://github.com/duanruiying/DryInterRouter.git",
        "tag": "0.0.2"
    },
    "description": "TODO: Swiftu5de5u7a0bu5185u90e8u72ecu7acbu8defu7531uff0cu7528u4e8eu89e3u8026u89c6u56feu63a7u5236u5668u4e4bu95f4u7684push.",
    "swift_versions": "5",
    "platforms": {
        "ios": "10.0"
    },
    "requires_arc": true,
    "user_target_xcconfig": {
        "OTHER_LDFLAGS": [
            "-w"
        ]
    },
    "pod_target_xcconfig": {
        "OTHER_LDFLAGS": [
            "-w"
        ]
    },
    "source_files": "DryInterRouter/Classes/Code/**/*",
    "frameworks": [
        "UIKit",
        "Foundation"
    ],
    "swift_version": "5"
}

Pin It on Pinterest

Share This