我尝试为另一个类调用通知
//哪个在Class
中- (void)onDidFinishLaunchingNotification:(NSNotification*)notification
{
NSLOG(@"onDidFinishLaunchingNotification");
}
从另一个类调用通知 //哪个在B组
[[NSNotificationCenter defaultCenter]addObserver:nil selector:@selector(onDidFinishLaunchingNotification:) name:nil object:nil];
答案 0 :(得分:1)
在A类中,使用名称
添加self作为通知的观察者[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onDidFinishLaunchingNotification:)
name:YourOnDidFinishLaunchingNotificationName
object:nil];
在B类中,使用-postNotificationName:object:
发布通知:
[[NSNotificationCenter defaultCenter] postNotificationName:YourOnDidFinishLaunchingNotificationName
object:nil];
答案 1 :(得分:1)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onDidFinishLaunchingNotification:)
name:YourOnDidFinishLaunchingNotificationName
object:nil];
我认为您应该查看addObserver:selector:name:object:
的文档这里使用NSNotification