Extract method to handle weak self only once

This commit is contained in:
Raimund Wege
2017-08-18 13:48:16 +02:00
parent fe98544ffd
commit c33c6592dd
@@ -57,12 +57,7 @@ class TrackingViewController : UIViewController {
preferredStyle: .alert
)
let okAction = UIAlertAction(title: Translation.Common.OK.String, style: .default) { [weak self] action in
LocationManager.sharedManager.stopTracking()
SVProgressHUD.show()
self?.sessionController.gpsFixController.sendAll(completion: { (withSuccess) in
SVProgressHUD.popActivity()
self?.dismiss(animated: true, completion: nil)
})
self?.stopTracking()
}
let cancelAction = UIAlertAction(title: Translation.Common.Cancel.String, style: .cancel, handler: nil)
alertController.addAction(okAction)
@@ -70,6 +65,15 @@ class TrackingViewController : UIViewController {
present(alertController, animated: true, completion: nil)
}
fileprivate func stopTracking() {
LocationManager.sharedManager.stopTracking()
SVProgressHUD.show()
self.sessionController.gpsFixController.sendAll(completion: { (withSuccess) in
SVProgressHUD.popActivity()
self.dismiss(animated: true, completion: nil)
})
}
}
// MARK: - UITableViewDataSourceDelegate