Hey there, so I've got an NSObject subclass sending out a message via开发者_运维百科 the notification center, and I'm sending out my notifications out to the object nil but the only object that can receive notifications is the one sending them
I've got two notifications being sent out at the same time (to test if it is a threading issue)
[[NSNotificationCenter defaultCenter] postNotificationName:kWGAskingForAuthToken object:nil];
int status = 123;
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"RAR" forKey:@"Status"];
NSNotification *note = [NSNotification notificationWithName:kWGAskingForAuthToken object:nil userInfo:userInfo];
[[NSNotificationCenter defaultCenter] performSelectorOnMainThread:@selector(postNotification:) withObject:note waitUntilDone:YES];
and my observers are just as simple
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMyEvent:)name:kWGAskingForAuthToken object:nil];
it's the same observer in a separate object which doesnt recieve the notification
This looks like the proper way to me. The only question is "where is kWGAskingForAuthToken defined?" Is it possible it's defined in more than one place? Possibly differently?
It's a shame but I never managed to find an answer to this, instead I just started sending messages to objects instead of using them globally.
精彩评论