快速使用 NSNotificationCenter iOS通知

来源:互联网 发布:高中英语在线听力软件 编辑:程序博客网 时间:2024/05/22 12:10

   

 //创建一个消息

    

 [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(notice:)name:@"123"object:nil];



 //发送消息

    

 [[NSNotificationCenterdefaultCenter]postNotificationName:@"123"object:niluserInfo:nil];


 -(void)notice:(id)userInfo{

    

    NSLog(@"zylmm");

    

    // userInfo等于post 过来的userInfo

}

// 通知多对多(随便玩,能实现好多东西。别忘记移除通知), 可以创建多个同名通知    可以多个页面post一个通知(这句多余)


1 0
原创粉丝点击