From ba39c4a5e413a6b38a276ebe5594bc62a1cb89b5 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Fri, 26 May 2017 09:58:27 -0500 Subject: [PATCH] Fixing retain cycles in charts view controllers --- Loop/View Controllers/ChartsTableViewController.swift | 4 ++-- Loop/View Controllers/PredictionTableViewController.swift | 2 +- Loop/View Controllers/StatusTableViewController.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Loop/View Controllers/ChartsTableViewController.swift b/Loop/View Controllers/ChartsTableViewController.swift index 13b5588731..8eec318e6e 100644 --- a/Loop/View Controllers/ChartsTableViewController.swift +++ b/Loop/View Controllers/ChartsTableViewController.swift @@ -30,10 +30,10 @@ class ChartsTableViewController: UITableViewController, UIGestureRecognizerDeleg let notificationCenter = NotificationCenter.default notificationObservers += [ - notificationCenter.addObserver(forName: .UIApplicationWillResignActive, object: UIApplication.shared, queue: .main) { _ in + notificationCenter.addObserver(forName: .UIApplicationWillResignActive, object: UIApplication.shared, queue: .main) { [unowned self] _ in self.active = false }, - notificationCenter.addObserver(forName: .UIApplicationDidBecomeActive, object: UIApplication.shared, queue: .main) { _ in + notificationCenter.addObserver(forName: .UIApplicationDidBecomeActive, object: UIApplication.shared, queue: .main) { [unowned self] _ in self.active = true } ] diff --git a/Loop/View Controllers/PredictionTableViewController.swift b/Loop/View Controllers/PredictionTableViewController.swift index 72dd55d39e..94d83eea1f 100644 --- a/Loop/View Controllers/PredictionTableViewController.swift +++ b/Loop/View Controllers/PredictionTableViewController.swift @@ -32,7 +32,7 @@ class PredictionTableViewController: ChartsTableViewController, IdentifiableClas let notificationCenter = NotificationCenter.default notificationObservers += [ - notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { note in + notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { [unowned self] note in let context = note.userInfo?[LoopDataManager.LoopUpdateContextKey] as! LoopDataManager.LoopUpdateContext.RawValue DispatchQueue.main.async { switch LoopDataManager.LoopUpdateContext(rawValue: context) { diff --git a/Loop/View Controllers/StatusTableViewController.swift b/Loop/View Controllers/StatusTableViewController.swift index a531e521e8..1083d3f91a 100644 --- a/Loop/View Controllers/StatusTableViewController.swift +++ b/Loop/View Controllers/StatusTableViewController.swift @@ -44,7 +44,7 @@ final class StatusTableViewController: ChartsTableViewController { let notificationCenter = NotificationCenter.default notificationObservers += [ - notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { note in + notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { [unowned self] note in let context = note.userInfo?[LoopDataManager.LoopUpdateContextKey] as! LoopDataManager.LoopUpdateContext.RawValue DispatchQueue.main.async { switch LoopDataManager.LoopUpdateContext(rawValue: context) { @@ -64,7 +64,7 @@ final class StatusTableViewController: ChartsTableViewController { self.reloadData(animated: true) } }, - notificationCenter.addObserver(forName: .LoopRunning, object: deviceManager.loopManager, queue: nil) { _ in + notificationCenter.addObserver(forName: .LoopRunning, object: deviceManager.loopManager, queue: nil) { [unowned self] _ in DispatchQueue.main.async { self.hudView.loopCompletionHUD.loopInProgress = true }