Use postNotificationName:object:userInfo: and bind any parameter you want to pass in the userInfo dictionary.
Example:
You can post a notification like this
NSDictionary * userInfo = @{ @"toOrientation" : @(toOrientation) }; [[NSNotificationCenter defaultCenter] postNotificationName:@"willAnimateRotationToInterfaceOrientation" object:nil userInfo:userInfo];
And then retrieve the information you submitted by doing:
- (void)willAnimateRotationToInterfaceOrientation:(NSNotification *)n { UIInterfaceOrientation toOrientation = (UIInterfaceOrientation)[n.userInfo[@"toOrientation"] intValue];
To summarize what was seen above, the selector used to process notifications accepts one optional parameter of type NSNotification , and you can store any information that you want to skip inside the userInfo dictionary.
Gabriele petronella
source share