ACRouter
ACRouter copied to clipboard
URL Router for Swift
ACRouter
Introduce
A simple router for swift 中文文档
Process

Requirements
swift3+ and xcode8+
Installation
pod "ACRouter"
How To Use
- 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
}
}
- RegisterRouter for your CustomViewController
ACRouter.addRouter("AA://bb/cc/:p1", classString: "CustomViewController")
- 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
- 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
- [X] ~~Add Interceptor for router~~
- [X] ~~Add Test for router~~
- [X] ~~Add
openURLfailed action~~ - [X] Add
relocation - [ ]
openURLnot only support Viewcontroller jumping
Author
License
ACRouter is available under the MIT license. See the LICENSE file for more info.