iOS 有参数的通知 有对象的参数的通知

来源:互联网 发布:布隆过滤器 java 编辑:程序博客网 时间:2024/06/04 01:14

//有参数的通知

 [[NSNotificationCenterdefaultCenter]postNotificationName:@"YijianSend"object:niluserInfo:@{@"text":self.textViewStr}];


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

- (void)YijianSend:(NSNotification *)noti{

    

    self.yjtextStr = noti.userInfo[@"text"];

    

}


-(void)dealloc{

    [[NSNotificationCenterdefaultCenter] removeObserver:self];

}


//有对象的参数 通知 

  [[NSNotificationCenterdefaultCenter]postNotificationName:@"ExitGroupToRemove"object:group];

  //接收移除解散群组的通知

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


//解散群组接受通知

-(void)ExitGroupToRemove:(NSNotification *)noti{

    EMGroup *group = noti.object;

    [self.myGroupArrayremoveObject:group];

    [self.tableViewreloadData];

    

}


0 0