gives the compiler the chance to warn you about potential leaks
authorbuff <andreas@pep-project.org>
Mon, 10 Sep 2018 19:13:50 +0200
changeset 630862e8d9011c28
parent 6307 8bd7fcc42a97
child 6309 c744a1bae9b7
gives the compiler the chance to warn you about potential leaks
pEpForiOS/UI/EmailDisplay/EmailViewController.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Mon Sep 10 18:14:03 2018 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Mon Sep 10 19:13:50 2018 +0200
     1.3 @@ -89,7 +89,7 @@
     1.4              if !handshakeCombos.isEmpty {
     1.5                  let tapGestureRecognizer = UITapGestureRecognizer(
     1.6                      target: self,
     1.7 -                    action: #selector(self.showHandshakeView(gestureRecognizer:)))
     1.8 +                    action: #selector(showHandshakeView(gestureRecognizer:)))
     1.9                  privacyStatusIcon.addGestureRecognizer(tapGestureRecognizer)
    1.10              }
    1.11          }
    1.12 @@ -120,7 +120,7 @@
    1.13                  action: nil)
    1.14              flexibleSpace.tag = BarButtonType.space.rawValue
    1.15  
    1.16 -            self.toolbarItems?.append(contentsOf: [flexibleSpace,item])
    1.17 +            toolbarItems?.append(contentsOf: [flexibleSpace,item])
    1.18          } else {
    1.19              removePepButton()
    1.20          }
    1.21 @@ -130,19 +130,19 @@
    1.22          // Make sure the NavigationBar is shown, even if the previous view has hidden it.
    1.23          navigationController?.setNavigationBarHidden(false, animated: false)
    1.24  
    1.25 -        self.title = NSLocalizedString("Message", comment: "Message view title")
    1.26 +        title = NSLocalizedString("Message", comment: "Message view title")
    1.27  
    1.28          setupDestructiveButtonIcon()
    1.29  
    1.30          tableData?.filterRows(message: message)
    1.31  
    1.32          if messageId <= 0 {
    1.33 -            self.previousMessage.isEnabled = false
    1.34 +            previousMessage.isEnabled = false
    1.35          } else {
    1.36 -            self.previousMessage.isEnabled = true
    1.37 +            previousMessage.isEnabled = true
    1.38          }
    1.39  
    1.40 -        self.showPepRating()
    1.41 +        showPepRating()
    1.42  
    1.43          DispatchQueue.main.async {
    1.44              self.checkMessageReEvaluation()
    1.45 @@ -162,15 +162,15 @@
    1.46      }
    1.47  
    1.48      private func configureSplitViewBackButton() {
    1.49 -        self.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
    1.50 -        self.navigationItem.leftItemsSupplementBackButton = true
    1.51 +        navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
    1.52 +        navigationItem.leftItemsSupplementBackButton = true
    1.53      }
    1.54  
    1.55      private func configureOKButton() {
    1.56          if (shouldShowOKButton) {
    1.57              let okButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: .okButtonPressed)
    1.58 -            self.navigationItem.leftBarButtonItems? = [okButton]
    1.59 -            self.navigationItem.hidesBackButton = true
    1.60 +            navigationItem.leftBarButtonItems? = [okButton]
    1.61 +            navigationItem.hidesBackButton = true
    1.62          }
    1.63      }
    1.64  
    1.65 @@ -333,7 +333,7 @@
    1.66          if let m = folderShow?.messageAt(index: messageId) {
    1.67              message = m
    1.68          }
    1.69 -        self.tableView.reloadData()
    1.70 +        tableView.reloadData()
    1.71          configureView()
    1.72      }
    1.73  
    1.74 @@ -342,7 +342,7 @@
    1.75          if let m = folderShow?.messageAt(index: messageId) {
    1.76              message = m
    1.77          }
    1.78 -        self.tableView.reloadData()
    1.79 +        tableView.reloadData()
    1.80          configureView()
    1.81      }
    1.82  
    1.83 @@ -350,12 +350,24 @@
    1.84          // The ReplyAllPossibleChecker() should be pushed into the view model
    1.85          // as soon as there is one.
    1.86          let alert = ReplyAlertCreator(replyAllChecker: ReplyAllPossibleChecker())
    1.87 -            .withReplyOption { action in
    1.88 -                self.performSegue(withIdentifier: .segueReplyFrom , sender: self)
    1.89 -            }.withReplyAllOption(forMessage: message) { action in
    1.90 -                self.performSegue(withIdentifier: .segueReplyAllForm , sender: self)
    1.91 -            }.withFordwardOption { action in
    1.92 -                self.performSegue(withIdentifier: .segueForward , sender: self)
    1.93 +            .withReplyOption { [weak self] action in
    1.94 +                guard let me = self else {
    1.95 +                    Log.shared.errorAndCrash(component: #function, errorString: "Lost myself")
    1.96 +                    return
    1.97 +                }
    1.98 +                me.performSegue(withIdentifier: .segueReplyFrom , sender: self)
    1.99 +            }.withReplyAllOption(forMessage: message) { [weak self] action in
   1.100 +                guard let me = self else {
   1.101 +                    Log.shared.errorAndCrash(component: #function, errorString: "Lost myself")
   1.102 +                    return
   1.103 +                }
   1.104 +                me.performSegue(withIdentifier: .segueReplyAllForm , sender: self)
   1.105 +            }.withFordwardOption { [weak self] action in
   1.106 +                guard let me = self else {
   1.107 +                    Log.shared.errorAndCrash(component: #function, errorString: "Lost myself")
   1.108 +                    return
   1.109 +                }
   1.110 +                me.performSegue(withIdentifier: .segueForward , sender: self)
   1.111              }.withCancelOption()
   1.112              .build()
   1.113  
   1.114 @@ -620,8 +632,12 @@
   1.115  
   1.116          splitViewController?.preferredDisplayMode = .allVisible
   1.117  
   1.118 -        coordinator.animate(alongsideTransition: nil){ _ in
   1.119 -            self.setuptoolbar()
   1.120 +        coordinator.animate(alongsideTransition: nil){ [weak self] _ in
   1.121 +            guard let me = self else {
   1.122 +                Log.shared.errorAndCrash(component: #function, errorString: "Lost myself")
   1.123 +                return
   1.124 +            }
   1.125 +            me.setuptoolbar()
   1.126          }
   1.127      }
   1.128