一个UIViewController
将自身添加到默认中心:后导致 “EXC_BAD_ACCESS” 异常
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(editFood)
name:@"editFood"
object:nil];
然后一个UITableView
代表NSObject的职位NSNotification
:
[[NSNotificationCenter defaultCenter]
postNotificationName:@"editFood"
object:self];
在运行时它得到EXC_BAD_ACCESS异常。
defaultCenter
是否在某处被释放?当我从UIViewController向UIViewController发布通知时,同样的概念有效,但那应该不重要,对吧?
究竟它在哪里崩溃? – Till 2011-04-14 19:47:03
在你的场景中添加'[[NSNotificationCenter defaultCenter] removeObserver:self]'到' - (void)dealloc {}'方法可能会为你解决这个问题。它为我工作;我遇到了同样的问题。祝你好运! – nodebase 2014-09-22 02:05:54