这是我得到的错误
Thread 1:EXC_BAD_ACCESS (code=2, address=0xb7ffffc)
在这条线上
[[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish
object:target
userInfo:[[userInfo copy] autorelease]];
在 AsyncImageView.m 文件中。
该错误会停止代码,但如果我继续在调试器中,它会卡住 Xcode 并关闭它。我该如何解决这个问题?
最佳答案
在 init 中需要注册,在 dealloc 中需要取消注册!
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:AsyncImageLoadDidFinish object:nil];
或者
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
关于xcode - NSNotification EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11543388/