【发布时间】:2011-08-05 20:10:43
【问题描述】:
UIViewController 将自己添加到默认中心:
[[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 发布通知时,同样的概念也适用,但这不重要,对吧?
【问题讨论】:
-
到底是哪里崩溃了?
-
在你的场景中添加
[[NSNotificationCenter defaultCenter] removeObserver:self]到-(void)dealloc{}方法可能会为你解决这个问题。它对我有用;我遇到了和你一样的问题。祝你好运!
标签: ios objective-c iphone exc-bad-access nsnotificationcenter