Skip to content

Instantly share code, notes, and snippets.

@bouchtaoui-dev
Last active September 30, 2019 12:56
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 bouchtaoui-dev/378525f79c0f675d6762dfdb5d0af49f to your computer and use it in GitHub Desktop.
Save bouchtaoui-dev/378525f79c0f675d6762dfdb5d0af49f to your computer and use it in GitHub Desktop.
NSNotification example
- (void) subscribeNotificationWithName: (NSString*) name {
[ [NSNotificationCenter defaultCenter ] addObserver: self
selector: @selector(didReceiveNotification:)
name: name
object: nil ];
}
- (void) didReceiveNotification: (NSNotification *) notification {
NSLog(@"didReceiveNotification");
NSString *title = (NSString*)notification.object;
NSDictionary *info = notification.userInfo;
NSString *message = [info objectForKey: @"error.message"];
}
- (void) postNotification {
NSDictionary *info = [NSDictionary dictionaryWithObject: ErrorMessage
forKey: @"error.message"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"some message"
object: @"Connection Status"
userInfo: info];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment