我在下面用于注册通知: -
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(AllSearch:) name:filter object:nil];
-(void)AllSearch:(NSNotification *)notification
{
NSLog(@"abc");
}
我用这段代码发布通知: -
[[NSNotificationCenter defaultCenter] postNotificationName:filter object:nil];
但是“ AllSearch ”方法没有调用。
答案 0 :(得分:0)
plz检查你必须先添加addObserver的代码
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(AllSearch:) name:filter object:nil];
befor postNotification
[[NSNotificationCenter defaultCenter] postNotificationName:filter object:nil];