Skip to content

Instantly share code, notes, and snippets.

@kateinoigakukun
Created August 27, 2017 12:01
Show Gist options
  • Save kateinoigakukun/9810de1ca312eb5da1c9b2f71dcbe767 to your computer and use it in GitHub Desktop.
Save kateinoigakukun/9810de1ca312eb5da1c9b2f71dcbe767 to your computer and use it in GitHub Desktop.
おうちプロジェクトRouter #swift #CodePiece
extension Router {
mutating func registerRouting() {
register(routing: TweetRoute.self) { (route: TweetRoute) -> UIViewController in
return TweetDetailViewController.ex.make(with: (id: route.id, userName: route.userName))
}
}
struct TweetRoute: Routing {
static var scheme: String { return "https://" }
static var pattern: RoutingFormat {
return "twitter.com"/+/String.parameter/+/"status"/+/Int.parameter
}
let id: Int
let userName: String
init(matched: [MatchedType]) {
userName = matched[0].string
id = matched[1].integer
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment