A simple router for swift 中文文档
swift3+ and xcode8+
pod "ACRouter"
- 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")
- 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: )
- 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.
Add Interceptor for routerAdd Test for router- Add
openURL
failed action - Add
relocation
openURL
not only support Viewcontroller jumping
ACRouter is available under the MIT license. See the LICENSE file for more info.