简而言之,我在(in ) 中注册了以下NSNotification
侦听器:ClassA
viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playSong) name:@"playNotification" object:nil];
我在中声明了选择器ClassA.h
:
- (void)playSong:(NSNotification *) notification;
实施如下:
- (void)playSong:(NSNotification *) notification {
NSString *theTitle = [notification object];
NSLog(@"Play stuff", theTitle);
}
在ClassB
(在tableView:didSelectRowAtIndexPath:
方法中)我有:
NSInteger row = [indexPath row];
NSString *stuff = [playlistArray objectAtIndex:row];
[[NSNotificationCenter defaultCenter] postNotificationName:@"playNotification" object:stuff];
这一切都以一条错误消息告终:
“无法识别的选择器发送到实例”
在playSong
调用方法之前。
有人可以帮我吗?从一个控制器向另一个控制器发布通知时我忘记了什么?