Skip to content

Instantly share code, notes, and snippets.

@efremidze
Last active March 12, 2017 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efremidze/349aa8d950b0d57ecac949fd66a4233f to your computer and use it in GitHub Desktop.
Save efremidze/349aa8d950b0d57ecac949fd66a4233f to your computer and use it in GitHub Desktop.
import UIKit
class NotificationManager {
private var tokens = [String: AnyObject]()
deinit {
tokens.values.forEach { NC.removeObserver($0) }
}
func addObserver(forName name: NSNotification.Name, object obj: Any?, queue: OperationQueue?, using block: @escaping (Notification) -> Void) {
tokens[name.rawValue] = NC.addObserver(forName: name, object: obj, queue: queue, using: block)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment