Эх сурвалжийг харах

declared weak self in notifications

nayooti 5 жил өмнө
parent
commit
5ec1742b14

+ 6 - 6
deltachat-ios/Controller/ChatListController.swift

@@ -82,22 +82,22 @@ class ChatListController: UITableViewController {
         msgChangedObserver = nc.addObserver(
             forName: dcNotificationChanged,
             object: nil,
-            queue: nil) { _ in
-                self.viewModel.refreshData()
+            queue: nil) { [weak self] _ in
+                self?.viewModel.refreshData()
 
         }
         incomingMsgObserver = nc.addObserver(
             forName: dcNotificationIncoming,
             object: nil,
-            queue: nil) { _ in
-                self.viewModel.refreshData()
+            queue: nil) { [weak self] _ in
+                self?.viewModel.refreshData()
         }
         viewChatObserver = nc.addObserver(
             forName: dcNotificationViewChat,
             object: nil,
-            queue: nil) { notification in
+            queue: nil) { [weak self] notification in
                 if let chatId = notification.userInfo?["chat_id"] as? Int {
-                    self.showChat(chatId: chatId)
+                    self?.showChat(chatId: chatId)
                 }
         }
     }

+ 4 - 2
deltachat-ios/Controller/NewGroupController.swift

@@ -74,7 +74,8 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
             forName: dcNotificationChatModified,
             object: nil,
             queue: nil
-        ) { notification in
+        ) { [weak self] notification in
+            guard let self = self else { return }
             if let ui = notification.userInfo {
                 if let chatId = ui["chat_id"] as? Int {
                     if self.groupChatId == 0 || chatId != self.groupChatId {
@@ -90,7 +91,8 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
             forName: dcNotificationChanged,
             object: nil,
             queue: nil
-        ) { notification in
+        ) { [weak self] notification in
+            guard let self = self else { return }
             if let ui = notification.userInfo {
                 if let chatId = ui["chat_id"] as? Int {
                     if self.groupChatId == 0 || chatId != self.groupChatId {