A UIViewController将自己添加到默认中心:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(editFood)
name:@"editFood"
object:nil];
Run Code Online (Sandbox Code Playgroud)
然后UITableView代表NSObject发布一个NSNotification:
[[NSNotificationCenter defaultCenter]
postNotificationName:@"editFood"
object:self];
Run Code Online (Sandbox Code Playgroud)
在运行时,它会获得EXC_BAD_ACCESS异常.
是在defaultCenter哪里获得释放?当我从UIViewController向UIViewController发布通知时,同样的概念也有效,但这不重要,对吧?