From c33c6592dd2256ba98c750bed463149c56718850 Mon Sep 17 00:00:00 2001 From: Raimund Wege Date: Fri, 18 Aug 2017 13:48:16 +0200 Subject: [PATCH] Extract method to handle weak self only once --- .../SAPTracker/TrackingViewController.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ios/SAPTracker/src/xcode/SAPTracker/TrackingViewController.swift b/ios/SAPTracker/src/xcode/SAPTracker/TrackingViewController.swift index c095028980c..8e56dedd75a 100644 --- a/ios/SAPTracker/src/xcode/SAPTracker/TrackingViewController.swift +++ b/ios/SAPTracker/src/xcode/SAPTracker/TrackingViewController.swift @@ -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