NSNotification目标C
答
发送通知:
[[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:nil];
要注册一个类来接收通知(通常在init方法):
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myCallback:) name:@"MyNotification" object:nil];
- (void)myCallback:(NSNotification *)notification
{
... do something
}
然后删除观察者在你的dealloc
[[NSNotificationCenter defaultCenter] removeObserver:self];
[从这里您可以开始,认真!!](http://www.google.com/search?q=NSNotification)和特别[this one](http://stackoverflow.com/q/1900352/593709) – 2012-02-06 10:21:04
[doc](https://developer.apple.com/library/IOs/#documentation/Cocoa/Reference/Foundation/Classes/NSNotification_Class/Reference/Reference.html)? – 2012-02-06 10:21:57