summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMojgan <Mojgan.jelodar@codic.se>2023-06-19 14:14:06 +0200
committerMojgan <Mojgan.jelodar@codic.se>2023-06-19 14:14:06 +0200
commit2b3fc7f9b43dc577957ce8ef6f257e7cba266752 (patch)
tree9ae40fbe58c54acc8d0b8e9e802f5d152ef007be
parent1735c77d1e7af0652631a6d04b88edc7d3eb5398 (diff)
downloadmullvadvpn-2b3fc7f9b43dc577957ce8ef6f257e7cba266752.tar.xz
mullvadvpn-2b3fc7f9b43dc577957ce8ef6f257e7cba266752.zip
Fix callback calling at handlers
-rw-r--r--ios/MullvadVPN/Classes/CustomAlertViewController.swift8
-rw-r--r--ios/MullvadVPN/Operations/PresentAlertOperation.swift4
2 files changed, 4 insertions, 8 deletions
diff --git a/ios/MullvadVPN/Classes/CustomAlertViewController.swift b/ios/MullvadVPN/Classes/CustomAlertViewController.swift
index 42ceaf3c4b..5a99673a0d 100644
--- a/ios/MullvadVPN/Classes/CustomAlertViewController.swift
+++ b/ios/MullvadVPN/Classes/CustomAlertViewController.swift
@@ -94,11 +94,6 @@ class CustomAlertViewController: UIViewController {
}
}
- override func viewDidDisappear(_ animated: Bool) {
- super.viewDidDisappear(animated)
- handlers.removeAll()
- }
-
func addAction(title: String, style: ActionStyle, handler: (() -> Void)? = nil) {
// The presence of a button should reset any custom button margin to default.
containerView.directionalLayoutMargins.bottom = UIMetrics.CustomAlert.containerMargins.bottom
@@ -183,8 +178,9 @@ class CustomAlertViewController: UIViewController {
if let handler = handlers[button] {
handler()
}
-
didDismiss?()
+ didDismiss = nil
+ handlers.removeAll()
}
}
}
diff --git a/ios/MullvadVPN/Operations/PresentAlertOperation.swift b/ios/MullvadVPN/Operations/PresentAlertOperation.swift
index dda17b15af..7dff3399f6 100644
--- a/ios/MullvadVPN/Operations/PresentAlertOperation.swift
+++ b/ios/MullvadVPN/Operations/PresentAlertOperation.swift
@@ -37,8 +37,8 @@ final class PresentAlertOperation: AsyncOperation {
}
override func main() {
- alertController.didDismiss = {
- self.finish()
+ alertController.didDismiss = { [weak self] in
+ self?.finish()
}
presentingController.present(alertController, animated: true) {