diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-07-27 16:58:32 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-07-28 11:21:51 +0200 |
| commit | 2dbef1241b671783dc5674b7cb646dc10d8e6624 (patch) | |
| tree | db99a4be4f32329a5fa3a5fb2317aa15aa6f4dfe | |
| parent | ed00aec6a78497c2698acc63943ac69c5c41271b (diff) | |
| download | mullvadvpn-2dbef1241b671783dc5674b7cb646dc10d8e6624.tar.xz mullvadvpn-2dbef1241b671783dc5674b7cb646dc10d8e6624.zip | |
CustomTextView: release notification block observer
| -rw-r--r-- | ios/MullvadVPN/CustomTextView.swift | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ios/MullvadVPN/CustomTextView.swift b/ios/MullvadVPN/CustomTextView.swift index 8467511cb1..aed22fe07e 100644 --- a/ios/MullvadVPN/CustomTextView.swift +++ b/ios/MullvadVPN/CustomTextView.swift @@ -81,6 +81,8 @@ class CustomTextView: UITextView { } } + private var notificationObserver: Any? + override init(frame: CGRect, textContainer: NSTextContainer?) { super.init(frame: frame, textContainer: textContainer) @@ -112,7 +114,7 @@ class CustomTextView: UITextView { self.textContainer.lineFragmentPadding = 0 // Handle placeholder visibility - NotificationCenter.default.addObserver( + notificationObserver = NotificationCenter.default.addObserver( forName: NSTextStorage.didProcessEditingNotification, object: textStorage, queue: OperationQueue.main) { [weak self] (note) in @@ -126,6 +128,12 @@ class CustomTextView: UITextView { fatalError("init(coder:) has not been implemented") } + deinit { + if let notificationObserver = notificationObserver { + NotificationCenter.default.removeObserver(notificationObserver) + } + } + override func updateConstraints() { let textInset = placeholderTextInset |
