Reputation: 12683
I thought this would be very easy but is not. I searched here in stackOverflow and didn't find an answer. I only want to create a NSNotification
like a variable.
I already configured the listener and have a valid function. So if I send:
[[NSNotificationCenter defaultCenter] postNotificationName:@"name" object:nil];
This works with no problems. But, if I try it in the same place with:
NSNotification *test = [NSNotification notificationWithName:@"name" object:nil];
[[NSNotificationCenter defaultCenter] postNotification:test];
It doesn't work. What am I doing wrong?
Edit
This error appear in XCode:
-[object function]: unrecognized selector sent to instance 0x190d90
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[object function]: unrecognized selector sent to instance 0x190d90'
Edit 2
Was a bug. I don't believe I start this question. There are a very small error in @"name", they are different in my code, like @"nname"
and @"name"
.
Because this I learn 2 things:
postNotification
. Only when there is no other way. This is difficult to debug and can cause error.#define NAME @"name"
will save a lot of time to me.Upvotes: 1
Views: 845
Reputation: 2183
It sounds to me like the problem is not in the way you are posting the notification, but rather in the way you are listening to it. You've probably told the listening class to call a selector that doesn't exist.
Upvotes: 2