I am trying to send some data using NSNotification but get stuck. Here is my code:
// Posting Notification
NSDictionary *orientationData;
if(iFromInterfaceOr
Your selector must have :
to accept parameters.
e.g.
@selector(orientationChanged:)
then in the method declaration it can accept the NSNotification
parameter.
You get an NSNotification object passed to your function. This includes the name, object and user info that you provided to the NSNotificationCenter.
- (void)orientationChanged:(NSNotification *)notification
{
NSDictionary *dict = [notification userInfo];
}
In swift To get userinfo object
let dict = notification.userInfo
print(dict)
You are posting the notification correctly. Please modify the Notification Observer like following.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
name:@"Abhinav" object:nil];
- (void)orientationChanged:(NSNotification *)notification
{
NSDictionary *dict = [notification userInfo];
}
I hope, this solution will work for you..