-
-
Save hsavit1/712f0b2d3f01c4dedf996fff73b3f592 to your computer and use it in GitHub Desktop.
This file contains 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