Access an NSNotification object

How do you access the NSDictionary that’s posted in the userInfo object of an NSNotification?

In the method you’ve picked to handle the notification, just access the object using:

    [notification userInfo]

Here’s a quick reminder of how they’re all created:
Post Notification:

[[NSNotificationCenter defaultCenter] postNotificationName:@"Feature Update" object:self userInfo:dict];

Observer:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleFeatureUpdate:) name:@"Feature Update" object:nil];

Selector:

- (void)handleFeatureUpdate:(NSNotification *)notification {
    NSLog(@"%@ updated", [notification userInfo]);
}

http://stackoverflow.com/questions/6748614/access-object-passed-in-nsnotification

Leave a Reply

Your email address will not be published. Required fields are marked *