您的位置:首页 > 产品设计 > UI/UE

NSNotification用法 1.点击发送一个通知。 - (void)menuItemClick:(id)sender; { [[NSNotificationCenter default

2011-09-21 10:04 555 查看
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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  menu object
相关文章推荐