Created
August 27, 2017 12:01
-
-
Save kateinoigakukun/9810de1ca312eb5da1c9b2f71dcbe767 to your computer and use it in GitHub Desktop.
おうちプロジェクトRouter #swift #CodePiece
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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