@@ -65,6 +65,30 @@ class ProjectsViewController: UIViewController, UITableViewDelegate, UITableView
65
65
navigationItem. leftBarButtonItem = UIBarButtonItem ( title: " Log Out " , style: . plain, target: self , action: #selector( logOutButtonDidClick) )
66
66
}
67
67
68
+ // :code-block-start: log-out-button-did-click
69
+ @objc func logOutButtonDidClick( ) {
70
+ let alertController = UIAlertController ( title: " Log Out " , message: " " , preferredStyle: . alert) ;
71
+ alertController. addAction ( UIAlertAction ( title: " Yes, Log Out " , style: . destructive, handler: {
72
+ alert -> Void in
73
+ print ( " Logging out... " ) ;
74
+ // :hide-start:
75
+ app. currentUser ( ) ? . logOut ( ) { ( error) in
76
+ DispatchQueue . main. sync {
77
+ print ( " Logged out! " ) ;
78
+ self . navigationController? . popViewController ( animated: true )
79
+ }
80
+ }
81
+ // :replace-with:
82
+ // // TODO: log out the app's currentUser, then, on the main thread, pop this
83
+ // // view controller from the navigation controller to navigate back to
84
+ // // the WelcomeViewController.
85
+ // :hide-end:
86
+ } ) )
87
+ alertController. addAction ( UIAlertAction ( title: " Cancel " , style: . cancel, handler: nil ) )
88
+ self . present ( alertController, animated: true , completion: nil )
89
+ }
90
+ // :code-block-end:
91
+
68
92
// :code-block-start: number-of-rows-in-section
69
93
func tableView( _ tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
70
94
// :hide-start:
@@ -78,6 +102,7 @@ class ProjectsViewController: UIViewController, UITableViewDelegate, UITableView
78
102
// return 0
79
103
// :hide-end:
80
104
}
105
+ // :code-block-end:
81
106
82
107
// :code-block-start: cell-for-row-at
83
108
func tableView( _ tableView: UITableView , cellForRowAt indexPath: IndexPath ) -> UITableViewCell {
@@ -125,27 +150,4 @@ class ProjectsViewController: UIViewController, UITableViewDelegate, UITableView
125
150
}
126
151
// :code-block-end:
127
152
128
- // :code-block-start: log-out-button-did-click
129
- @objc func logOutButtonDidClick( ) {
130
- let alertController = UIAlertController ( title: " Log Out " , message: " " , preferredStyle: . alert) ;
131
- alertController. addAction ( UIAlertAction ( title: " Yes, Log Out " , style: . destructive, handler: {
132
- alert -> Void in
133
- print ( " Logging out... " ) ;
134
- // :hide-start:
135
- app. currentUser ( ) ? . logOut ( ) { ( error) in
136
- DispatchQueue . main. sync {
137
- print ( " Logged out! " ) ;
138
- self . navigationController? . popViewController ( animated: true )
139
- }
140
- }
141
- // :replace-with:
142
- // // TODO: log out the app's currentUser, then, on the main thread, pop this
143
- // // view controller from the navigation controller to navigate back to
144
- // // the WelcomeViewController.
145
- // :hide-end:
146
- } ) )
147
- alertController. addAction ( UIAlertAction ( title: " Cancel " , style: . cancel, handler: nil ) )
148
- self . present ( alertController, animated: true , completion: nil )
149
- }
150
- // :code-block-end:
151
153
}
0 commit comments