Last active
June 17, 2016 16:13
-
-
Save andyyhope/ec73810237fbf2a1a641c22e4015fe8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Selector { | |
static let coffeeMadeNotification = #selector(Customer.drink(_:)) | |
} | |
class Customer { | |
@objc func drink(notification: NSNotification) { | |
print("Mmm... Coffee") | |
} | |
} | |
let customer = Customer() | |
Barista.addObserver(customer, selector: .coffeeMadeNotification, notification: .coffeeMade) | |
Barista.postNotification(.coffeeMade) | |
// prints: Mmm... Coffee | |
Barista.removeObserver(customer, notification: .coffeeMade) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment