开发者

NSNotifications only being sent within the same object

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜