Last active
December 10, 2015 10:43
-
-
Save joekr/4422401 to your computer and use it in GitHub Desktop.
Subscription With NSNotifications
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
- (void) getSubscriptionFromServer { | |
// call out to server | |
if(success == ture){ | |
[[NSNotificationCenter defaultCenter] postNotificationName:@"getSubscriptionFromServerPassed" object:nil]; | |
} else{ | |
[[NSNotificationCenter defaultCenter] postNotificationName:@"getSubscriptionFromServerFailed" object:nil]; | |
} | |
} |
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
- (void) findSubscription{ | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(subscriptionPassed) name:@"getSubscriptionFromServerPassed" object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(subscriptionFailed) name:@"getSubscriptionFromServerFailed" object:nil]; | |
[myObject getSubscriptionFromServer]; | |
} | |
- (void) subscriptionPassed{ | |
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"getSubscriptionFromServerPassed" object:nil]; | |
//Handle subscription call passed | |
} | |
- (void) subscriptionFailed{ | |
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"getSubscriptionFromServerFailed" object:nil]; | |
//Handle subscription call failed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment