ios下NSNotification的使用

第一步:注册NSNotificaiton

[[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(func:)

                                                 name:@"notifiName"

                                               object:nil];

 

实现接收到通知后回调方法

-(void) PlayVideo:(NSNotification *)notification {

}

 

第二步:发送通知

NSNotification *notification= [NSNotification notificationWithName:@"PlayVideo" object:showViewController userInfo:dict];

    [[NSNotificationCenter defaultCenter] postNotification:notification];

 

第三步:注销通知监听

  [[NSNotificationCenter defaultCenter]removeObserver:self

                                                  name:@"PlayVideo"

                                                object:nil];

posted @ 2014-12-22 17:17  我去ios  阅读(172)  评论(0编辑  收藏  举报