@@ -27,49 +27,49 @@ Now you need to configure Compass to use that URL scheme, a good place
2727to do this is in your ` AppDelegate `
2828
2929``` swift
30- func application (application : UIApplication,
31- didFinishLaunchingWithOptions launchOptions : [NSObject: AnyObject ]? ) -> Bool {
32- Compass.scheme = " compass"
33- return true
30+ func application (_ application : UIApplication,
31+ didFinishLaunchingWithOptions launchOptions : [UIApplicationLaunchOptionsKey: Any ]? ) -> Bool {
32+ Compass.scheme = " compass"
33+ return true
3434}
3535```
3636#### Step 3
3737Configure your application routes
3838
3939``` swift
40- func application (application : UIApplication,
41- didFinishLaunchingWithOptions launchOptions : [NSObject: AnyObject ]? ) -> Bool {
42- Compass.scheme = " compass"
43- Compass.routes = [" profile:{username}" , " login:{username}" , " logout" ]
44- return true
40+ func application (_ application : UIApplication,
41+ didFinishLaunchingWithOptions launchOptions : [UIApplicationLaunchOptionsKey: Any ]? ) -> Bool {
42+ Compass.scheme = " compass"
43+ Compass.routes = [" profile:{username}" , " login:{username}" , " logout" ]
44+ return true
4545}
4646```
4747#### Step 4
4848Set up your application to respond to the URLs, this can be done in the ` AppDelegate ` but its up to you to find a more suitable place for it depending on the size of your implementation.
4949
5050``` swift
51- func application (app : UIApplication,
52- openURL url : NSURL ,
53- options : [String : AnyObject ]) -> Bool {
54- guard let location = Compass.parse (url) else {
55- return false
56- }
51+ func application (_ app : UIApplication,
52+ open url : URL ,
53+ options : [UIApplicationOpenURLOptionsKey : Any ]) -> Bool {
54+ guard let location = Compass.parse (url) else {
55+ return false
56+ }
5757
58- let arguments = location.arguments
58+ let arguments = location.arguments
5959
60- switch location.path {
61- case " profile:{username}" :
62- let profileController = profileController (title : arguments[" {username}" ])
63- self .navigationController ? .pushViewController (profileController, animated : true )
64- case " login:{username}" :
65- let loginController = LoginController (title : arguments[" {username}" ])
66- self .navigationController ? .pushViewController (loginController, animated : true )
67- case " logout" :
68- logout ()
69- default : break
70- }
60+ switch location.path {
61+ case " profile:{username}" :
62+ let profileController = profileController (title : arguments[" {username}" ])
63+ self .navigationController ? .pushViewController (profileController, animated : true )
64+ case " login:{username}" :
65+ let loginController = LoginController (title : arguments[" {username}" ])
66+ self .navigationController ? .pushViewController (loginController, animated : true )
67+ case " logout" :
68+ logout ()
69+ default : break
70+ }
7171
72- return true
72+ return true
7373}
7474```
7575
@@ -109,16 +109,16 @@ router.routes = [
109109- Parse URL with ** Compass** and navigate to the route with a help of your
110110` Router ` instance.
111111``` swift
112- func application (app : UIApplication,
113- openURL url : NSURL ,
114- options : [String : AnyObject ]) -> Bool {
115- guard let location = Compass.parse (url) else {
116- return false
117- }
112+ func application (_ app : UIApplication,
113+ open url : URL ,
114+ options : [UIApplicationOpenURLOptionsKey : Any ]) -> Bool {
115+ guard let location = Compass.parse (url) else {
116+ return false
117+ }
118118
119- router.navigate (to : location, from : navigationController)
119+ router.navigate (to : location, from : navigationController)
120120
121- return true
121+ return true
122122}
123123```
124124
@@ -172,9 +172,9 @@ Add your own global function to easily navigate internally
172172import Compass
173173
174174public func navigate (urn : String ) {
175- let stringURL = " \( Compass.scheme ) \( urn ) "
175+ let stringUrl = " \( Compass.scheme ) \( urn ) "
176176 guard let appDelegate = UIApplication.sharedApplication ().delegate as? ApplicationDelegate,
177- url = NSURL (string : stringURL ) else { return }
177+ url = URL (string : stringUrl ) else { return }
178178
179179 appDelegate.handleURL (url)
180180}
0 commit comments