URL Router for Swift
A simple router for swift 中文文档
swift3+ and xcode8+
pod "ACRouter"
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
}
}
ACRouter.addRouter("AA://bb/cc/:p1", classString: "CustomViewController")
ACRouter.openURL("AA://bb/cc/content?value1=testInfo")
let registerDict = ["AA://bb/cc/:p1" : "CustomViewControllerOne", "AA://ee/ff" : "CustomViewControllerTwo"]
ACRouter.addRouter(registerDict)
ACRouter.generate(_ patternString: params: jumpType: )
It will parse patternString and embed the params and the jumpType in it
canOpenURL(_ urlString: )
removeRouter(_ patternString: )
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.
openURL
failed actionrelocation
openURL
not only support Viewcontroller jumpingACRouter is available under the MIT license. See the LICENSE file for more info.