我有一个由主线程启动的计时器。我正在从计时器处理程序发送通知 在五分之一的情况下,执行后通知代码时我会收到 EXC_BAD_ACCESS。
//Registering Notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(TestNotification:)
name:@"TestNotification" object:nil];
//Starting timer
timer = [NSTimer scheduledTimerWithTimeInterval:2
target:self
selector:@selector(timerhandler:)
userInfo:nil
repeats:YES];
//Posting notification from timer handler
[[NSNotificationCenter defaultCenter]
postNotificationName:@"TestNotification" object:nil];
谁能帮忙。
谢谢
最佳答案
乍一看,一个已注册
以接收通知的对象在解除分配
之前并未取消注册
。
导致通知中心向已释放的对象发送消息。
但是如果没有更多代码,就很难说更多。
关于objective-c - 从计时器处理程序 cocoa 发送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8854224/