Skip to content

WeakObserver (weak notification observer) for SPM.

Notifications You must be signed in to change notification settings

iWECon/WeakObserver

Repository files navigation

WeakObserver

A simple weak observer for Notification.

How to use?

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
        }
    }
}

Install

Swift Package Manager

.package("https://github.com/iWECon/WeakObserver", from: "2.0.0")