簡単に言うと、次のNSNotification
リスナーをClassA
(in 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
メソッドが呼び出される前。
誰かここで私を助けてくれませんか? あるコントローラーから別のコントローラーに通知を投稿するときに、何を忘れていますか?