Skip to content

Commit

Permalink
Update URLNavigable implementation example code on README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
devxoul committed Mar 2, 2016
1 parent dbf32a9 commit dc40c1c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,23 @@ View controllers should conform a protocol `URLNavigable` to be mapped with URLs
Parameter `URL` is an URL that is passed from `URLNavigator.pushURL()` and `URLNavigator.presentURL()`. Parameter `values` is a dictionary that contains URL placeholder keys and values.

```swift
class UserViewController: UIViewController, URLNavigable {
final class UserViewController: UIViewController, URLNavigable {

init(userID: Int) {
super.init(nibName: nil, bundle: nil)
// Initialize here...
}

convenience init?(URL: URLConvertible, values: [String : AnyObject]) {
// User id from URL placeholder is required!
// Let's assume that the user id is required
guard let userID = values["id"] as? Int else {
return nil
}
self.init()
self.init(userID: userID)
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

}
Expand Down

0 comments on commit dc40c1c

Please sign in to comment.