A simple weak observer for Notification.
import WeakObserver
class Controller: UIViewController {
var keyboardWeakObserver: NotificationWeakObserver?
override func viewDidLoad() {
super.viewDidLoad()
// No need to call `Notification.default.removeObserver(_:)`
keyboardWeakObserver = NotificationWeakObserver(self, name: UIResponder.keyboardWillChangeFrameNotification) { (notify) in
// do something
}
}
}
.package("https://github.com/iWECon/WeakObserver", from: "2.0.0")