iOS NSNotificationCenter 最基本使用

 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);
}
原文地址:https://www.cnblogs.com/qingjoin/p/3782260.html