Last active
August 12, 2016 11:06
-
-
Save ppeszko/7aa4733273458808be4a5d0db59c92b1 to your computer and use it in GitHub Desktop.
Sad View Controller example for https://medium.com/@PatrykPeszko/notification-pattern-a862ceff4226
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
| // It's just an example for notifications. The rest can be safely ignored :) | |
| class HappyPaymentViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| PaymentNotifications.accepted.observe(self, | |
| selector: #selector(HappyPaymentViewController.paymentNotificationReceived(_:))) | |
| PaymentNotifications.rejected.observe(self, | |
| selector: #selector(HappyPaymentViewController.paymentNotificationReceived(_:))) | |
| } | |
| func paymentServiceDidReturn(paymentResponse: PaymentResponse) { | |
| switch paymentResponse { | |
| case .Accepted(_): | |
| PaymentNotifications.accepted.post() | |
| case .Rejected(_): | |
| PaymentNotifications.rejected.post() | |
| } | |
| } | |
| func paymentNotificationReceived(notification: NSNotification) { | |
| //FIXIT: Write this code before release, okay? Bye, I'm off for vacation. ᕕ( ᐛ )ᕗ | |
| } | |
| deinit { | |
| NSNotificationCenter.defaultCenter().removeObserver(self) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment