summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ios/MullvadVPN/CustomTextView.swift10
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