ACRouter Save

URL Router for Swift

Project README

ACRouter

CI Status Version License Platform

Introduce

A simple router for swift 中文文档

Process

sdf

Requirements

swift3+ and xcode8+

Installation

pod "ACRouter"

How To Use

  1. CustomViewController inherit ACRouterable, and implement the func of registerAction.
class CustomViewController: UIViewController, ACRouterable {
    static func registerAction(info: [String : AnyObject]) -> AnyObject {
        let newInstance = LoginViewController()
        if let title = info["username"] as? String {
            newInstance.title = title
        }
        return newInstance
    }
}
  1. RegisterRouter for your CustomViewController
ACRouter.addRouter("AA://bb/cc/:p1", classString: "CustomViewController")
  1. OpenURL in you application
ACRouter.openURL("AA://bb/cc/content?value1=testInfo")

Convenience

  • Quickly add multiple router
let registerDict = ["AA://bb/cc/:p1" : "CustomViewControllerOne", "AA://ee/ff" : "CustomViewControllerTwo"]
ACRouter.addRouter(registerDict)
  • Quickly genarate jump
ACRouter.generate(_ patternString: params:  jumpType: )

It will parse patternString and embed the params and the jumpType in it

  • Check the request URL
canOpenURL(_ urlString: )
  • remove router
removeRouter(_ patternString: )

Custom Use

  1. AddRouter
ACRouter.addRouter(patternString:  priority: handle: )

It will store pattern information, and sort by priority reverse order 2. RequestRouter

ACRouter.requestURL(urlString: userInfo: )

Request the real urlString, and response the pattern information and the queries which contain the userInfo. if exist the same key, it will embed in array.

Todo list

  • Add Interceptor for router
  • Add Test for router
  • Add openURL failed action
  • Add relocation
  • openURL not only support Viewcontroller jumping

Author

[email protected]

License

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

Open Source Agenda is not affiliated with "ACRouter" Project. README Source: Archerlly/ACRouter
Stars
29
Open Issues
1
Last Commit
5 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating