NSNotification用法
1.点击发送一个通知。
- (void)menuItemClick:(id)sender;
{
[[NSNotificationCenter defaultCenter] postNotificationName:EVENT_SYSMENU_CLICK object:sender];
}
2.添加通知的监听
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(handler_menu_click:)
name:EVENT_SYSMENU_CLICK
object:nil];
3.实现得到通知时调用方法
- (void)handler_menu_click:(NSNotification *)noti;
{
NSLog(@"handler_menu_click %@",noti.object);
}