iOS NSNotificationCenter 最基本使用

时间:2014-06-12 12:40:55   收藏:0   阅读:224

 

 

 

bubuko.com,布布扣
 NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:2] , @"actcode",nil];
    //首先设置需要通知的方法。加入通知中心。比如当程序跑到这时就通知游戏
    [[NSNotificationCenter defaultCenter] postNotificationName:gameStartNotification object:nil userInfo:dic];



//调用时--------------------------------------------

//注册消息通知  捕获游戏start时的方法
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testNotify:) name:gameStartNotification object:nil];


//实现方法
-(void)testNotify:(NSNotification*)notify
{
    NSLog(@"testNotify:%@",notify);
}
bubuko.com,布布扣

 

iOS NSNotificationCenter 最基本使用,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!