Bläddra i källkod

Fix retain cycle caught by infer

Retain cycle at FLEXSystemLogTableViewController.m line 47, column 9 involving the following objects:
(1) a block that captures self
(2) object of type FLEXSystemLogTableViewController* --> _logController, last assigned on line 47
(3) object returned by withUpdateHandler of type FLEXOSLogController* --> _updateHandler, last assigned on line 47.
Ryan Olson (IG) 7 år sedan
förälder
incheckning
8b225d2046
1 ändrade filer med 16 tillägg och 10 borttagningar
  1. 16 10
      Classes/GlobalStateExplorers/SystemLog/FLEXSystemLogTableViewController.m

+ 16 - 10
Classes/GlobalStateExplorers/SystemLog/FLEXSystemLogTableViewController.m

@@ -27,17 +27,9 @@
 {
     [super viewDidLoad];
 
+    __weak typeof(self) weakSelf = self;
     id logHandler = ^(NSArray<FLEXSystemLogMessage *> *newMessages) {
-        self.title = @"System Log";
-
-        [self.logMessages addObjectsFromArray:newMessages];
-
-        // "Follow" the log as new messages stream in if we were previously near the bottom.
-        BOOL wasNearBottom = self.tableView.contentOffset.y >= self.tableView.contentSize.height - self.tableView.frame.size.height - 100.0;
-        [self.tableView reloadData];
-        if (wasNearBottom) {
-            [self scrollToLastRow];
-        }
+        [weakSelf handleUpdateWithNewMessages:newMessages];
     };
 
     _logMessages = [NSMutableArray array];
@@ -72,6 +64,20 @@
     self.tableView.tableHeaderView = self.searchController.searchBar;
 }
 
+- (void)handleUpdateWithNewMessages:(NSArray<FLEXSystemLogMessage *> *)newMessages
+{
+    self.title = @"System Log";
+
+    [self.logMessages addObjectsFromArray:newMessages];
+
+    // "Follow" the log as new messages stream in if we were previously near the bottom.
+    BOOL wasNearBottom = self.tableView.contentOffset.y >= self.tableView.contentSize.height - self.tableView.frame.size.height - 100.0;
+    [self.tableView reloadData];
+    if (wasNearBottom) {
+        [self scrollToLastRow];
+    }
+}
+
 - (void)viewWillAppear:(BOOL)animated
 {
     [super viewWillAppear:animated];