我有一个 NSNotificationCenter 选择器,
放在哪里?在委托(delegate)中(如果是,那么在哪里?)在 Controller 中?
将方法放在哪里。
我需要释放 NSNotificationCenter 吗?
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceNotificationReceived:) name:UIApplicationDidBecomeActiveNotification object:nil];
- (void)deviceNotificationReceived:(NSNotification *)notification
{
[self.soundMgr endInterruption];
}
最佳答案
deviceNotificationReceived:
方法必须是 addObserver:
参数的实例方法。在这个实例中是 self
,所以你的方法应该在同一个类中。
您不应该释放 NotificationCenter,因为您没有创建或保留它。
你的问题有点难懂,你问的是这个吗?
关于iphone - Objective-C - NSNotificationCenter 放在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7679635/