@@ -24,14 +24,14 @@ class ViewController: UIViewController, SessionExpirationDelegate {
2424 findSession ( )
2525 }
2626
27- private func initButtons( ) {
28- self . joinButton? . enabled = false
29- self . leaveButton? . enabled = false
27+ fileprivate func initButtons( ) {
28+ self . joinButton? . isEnabled = false
29+ self . leaveButton? . isEnabled = false
3030 }
3131
3232 // MARK: IBActions
3333
34- @IBAction func createSession( sender: AnyObject ) {
34+ @IBAction func createSession( _ sender: AnyObject ) {
3535 Pathshare . saveUserName ( " SDK User ios " ) { ( error) -> Void in
3636 if error != nil {
3737 NSLog ( " User: Error " )
@@ -43,46 +43,46 @@ class ViewController: UIViewController, SessionExpirationDelegate {
4343 }
4444 }
4545
46- @IBAction func joinSession( sender: AnyObject ) {
46+ @IBAction func joinSession( _ sender: AnyObject ) {
4747 self . session. joinUser { ( error) -> Void in
4848 if error != nil {
4949 NSLog ( " Session Join: Error " )
5050 NSLog ( error. description)
5151 } else {
5252 NSLog ( " Session Join: Success " )
53- self . createButton? . enabled = false
54- self . joinButton? . enabled = false
55- self . leaveButton? . enabled = true
53+ self . createButton? . isEnabled = false
54+ self . joinButton? . isEnabled = false
55+ self . leaveButton? . isEnabled = true
5656 }
5757 }
5858 }
5959
60- @IBAction func leaveSesson( sender: AnyObject ) {
60+ @IBAction func leaveSesson( _ sender: AnyObject ) {
6161 self . session. leaveUser { ( error) -> Void in
6262 if error != nil {
6363 NSLog ( " Session Leave: Error " )
6464 NSLog ( error. description)
6565 } else {
6666 NSLog ( " Session Leave: Success " )
67- self . leaveButton? . enabled = false
68- self . createButton? . enabled = true
67+ self . leaveButton? . isEnabled = false
68+ self . createButton? . isEnabled = true
6969
7070 self . deleteSessionIdentifier ( )
7171 }
7272 }
7373 }
7474
75- private func createSession( ) {
75+ fileprivate func createSession( ) {
7676 let destination = Destination ( )
7777 destination. identifier = " store1234 "
7878 destination. latitude = 47.378178
7979 destination. longitude = 8.539256
8080
8181 self . session = Session ( )
8282 self . session. name = " Example Session ios "
83- self . session. expirationDate = NSDate ( timeIntervalSinceNow: 3600 )
83+ self . session. expirationDate = Date ( timeIntervalSinceNow: 3600 )
8484 self . session. destination = destination
85- self . session. trackingMode = PSTrackingMode . Smart
85+ self . session. trackingMode = PSTrackingMode . smart
8686 self . session. delegate = self
8787
8888 self . session. save { ( error: NSError!) - > Void in
@@ -91,45 +91,44 @@ class ViewController: UIViewController, SessionExpirationDelegate {
9191 NSLog ( error. description)
9292 } else {
9393 NSLog ( " Session: Success " )
94- self . joinButton? . enabled = true
95- self . createButton? . enabled = false
94+ self . joinButton? . isEnabled = true
95+ self . createButton? . isEnabled = false
9696
9797 self . saveSessionIdentifier ( )
9898 }
99- }
99+ } as! ( Error ? ) -> Void as! ( Error ? ) -> Void as! ( Error ? ) -> Void as! ( Error ? ) -> Void as! ( Error ? ) -> Void as! ( Error ? ) -> Void as! ( Error ? ) -> Void
100100 }
101101
102- private func findSession( ) {
103- let sessionIdentifier = NSUserDefaults . standardUserDefaults ( ) . objectForKey ( sessionIdentifierKey) as? String
102+ fileprivate func findSession( ) {
103+ let sessionIdentifier = UserDefaults . standard . object ( forKey : sessionIdentifierKey) as? String
104104
105105 guard sessionIdentifier != nil else { return }
106106
107- Pathshare . findSessionWithIdentifier ( sessionIdentifier) { ( session, error) -> Void in
107+ Pathshare . findSession ( withIdentifier : sessionIdentifier) { ( session, error) -> Void in
108108 if session != nil {
109- session. delegate = self
109+ session? . delegate = self
110110 self . session = session
111111
112- self . createButton. enabled = false ;
113- self . joinButton. enabled = true ;
114- self . leaveButton. enabled = false ;
112+ self . createButton. isEnabled = false ;
113+ self . joinButton. isEnabled = true ;
114+ self . leaveButton. isEnabled = false ;
115115 }
116116 }
117117 }
118118
119- private func saveSessionIdentifier( ) {
120- NSUserDefaults . standardUserDefaults ( ) . setObject ( self . session. identifier, forKey: sessionIdentifierKey)
119+ fileprivate func saveSessionIdentifier( ) {
120+ UserDefaults . standard . set ( self . session. identifier, forKey: sessionIdentifierKey)
121121 }
122122
123- private func deleteSessionIdentifier( ) {
124- NSUserDefaults . standardUserDefaults ( ) . removeObjectForKey ( sessionIdentifierKey)
123+ fileprivate func deleteSessionIdentifier( ) {
124+ UserDefaults . standard . removeObject ( forKey : sessionIdentifierKey)
125125 }
126126
127127 // MARK: SessionExpirationDelegate
128128
129129 func sessionDidExpire( ) {
130- self . leaveButton? . enabled = false
131- self . joinButton? . enabled = false
132- self . createButton? . enabled = true
130+ self . leaveButton? . isEnabled = false
131+ self . joinButton? . isEnabled = false
132+ self . createButton? . isEnabled = true
133133 }
134134}
135-
0 commit comments