我使用 NSNotificationCenter:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playNow:) name:@"PlayNow" object:nil];
和发布:
[[NSNotificationCenter defaultCenter] postNotificationName:@"PlayNow" object:nil userInfo:noteInfoDictionary];
其中 self 是 @interface MyPlayer : NSObject 的实例
当我调用它时,它在大多数情况下工作得很好,但是当我解除分配并分配回 MyPlayer 实例时,我收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView playNow:]: unrecognized selector sent to instance 0x8929150'
我怎么可能从 UIView 收到错误?
最佳答案
你必须在 dealloc 中移除观察者:
[[NSNotificationCenter defaultCenter] removeObserver:self]
关于ios - NSNotification - 观察者不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16674222/