Skip to content

Commit ff60c70

Browse files
authored
Merge pull request #486 from LoopKit/memory-leak
Fixing retain cycles in charts view controllers
2 parents bedf33f + ba39c4a commit ff60c70

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Loop/View Controllers/ChartsTableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class ChartsTableViewController: UITableViewController, UIGestureRecognizerDeleg
3030

3131
let notificationCenter = NotificationCenter.default
3232
notificationObservers += [
33-
notificationCenter.addObserver(forName: .UIApplicationWillResignActive, object: UIApplication.shared, queue: .main) { _ in
33+
notificationCenter.addObserver(forName: .UIApplicationWillResignActive, object: UIApplication.shared, queue: .main) { [unowned self] _ in
3434
self.active = false
3535
},
36-
notificationCenter.addObserver(forName: .UIApplicationDidBecomeActive, object: UIApplication.shared, queue: .main) { _ in
36+
notificationCenter.addObserver(forName: .UIApplicationDidBecomeActive, object: UIApplication.shared, queue: .main) { [unowned self] _ in
3737
self.active = true
3838
}
3939
]

Loop/View Controllers/PredictionTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PredictionTableViewController: ChartsTableViewController, IdentifiableClas
3232
let notificationCenter = NotificationCenter.default
3333

3434
notificationObservers += [
35-
notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { note in
35+
notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { [unowned self] note in
3636
let context = note.userInfo?[LoopDataManager.LoopUpdateContextKey] as! LoopDataManager.LoopUpdateContext.RawValue
3737
DispatchQueue.main.async {
3838
switch LoopDataManager.LoopUpdateContext(rawValue: context) {

Loop/View Controllers/StatusTableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class StatusTableViewController: ChartsTableViewController {
4444
let notificationCenter = NotificationCenter.default
4545

4646
notificationObservers += [
47-
notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { note in
47+
notificationCenter.addObserver(forName: .LoopDataUpdated, object: deviceManager.loopManager, queue: nil) { [unowned self] note in
4848
let context = note.userInfo?[LoopDataManager.LoopUpdateContextKey] as! LoopDataManager.LoopUpdateContext.RawValue
4949
DispatchQueue.main.async {
5050
switch LoopDataManager.LoopUpdateContext(rawValue: context) {
@@ -64,7 +64,7 @@ final class StatusTableViewController: ChartsTableViewController {
6464
self.reloadData(animated: true)
6565
}
6666
},
67-
notificationCenter.addObserver(forName: .LoopRunning, object: deviceManager.loopManager, queue: nil) { _ in
67+
notificationCenter.addObserver(forName: .LoopRunning, object: deviceManager.loopManager, queue: nil) { [unowned self] _ in
6868
DispatchQueue.main.async {
6969
self.hudView.loopCompletionHUD.loopInProgress = true
7070
}

0 commit comments

Comments
 (0)