-2
我想知道在目標C約NSNotification,任何一個可以告訴我一下右源NSNotification目標C
我想知道在目標C約NSNotification,任何一個可以告訴我一下右源NSNotification目標C
這是一個非常漫問題。
如果你想在閱讀有關NSNotifications,頭NSNotification Class Reference上developer.apple.com
發送通知:
[[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