I’m sending a notification using:
[[NSNotificationCenter defaultCenter] postNotificationName:@"historyLoaded" object:jsonReturn];
And receiving the notification using:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(manageHistory:) name:@"historyLoaded" object:nil];
Then the method in the selector is:
- (void) manageHistory: (NSNotification *) historyData{
NSLog(@"this bit of code was run");
}
For some reaason the notification doesn’t get through. Can notifications be send and received from anywhere in the app?
The
objectparameter inpostNotificationshould be filled with an object which is “sending” the notification, or nil if the sender is not necessarily specified.If you want to pass some information along, you should use
postNotificationName:object:userInfoand put the information inuserInfodictionary instead.