嘿那里,所以我有一个 NSObject 子类通过通知中心发送消息,我将通知发送到对象 nil 但唯一可以接收通知的对象是发送它们的对象
我同时发送了两个通知(以测试它是否是线程问题)
[[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];
我的观察者也一样简单
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMyEvent:)name:kWGAskingForAuthToken object:nil];
它是一个单独的对象中的同一个观察者,它没有收到通知