I have the following code:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(cmd:)
name:@"cmdAvailable"
object:nil];
and I have the cmd as:
-(void) cmd: (NSNotification *) notification
in the same UIViewController. On the other UIViewController I have, I did this:
NSDictionary * userInfo = [NSDictionary dictionaryWithObject:requestUrl forKey:@"requestUrl"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"cmdAvailable" object:nil userInfo:userInfo];
Why is it not calling my cmd: (NSNotification *) notification method? I checked and that postNotification is getting called.
Shouldn’t it be this?
The documentation says this:
So object should be the object posting the notification, which is
selfUPDATE
The notification will contain three parts:
The receiver not only know that the message was sent, but what object sent it.