// 接收方
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.dataArray = [NSMutableArray arrayWithObjects:@"原始数据01",@"原始数据02", nil];
[self.view addSubview:self.testTableview];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noti:) name:@"noti" object:nil];
}
-(void)noti:(NSNotification *)noti
{
NSDictionary *dic = [noti userInfo];
NSArray * title = dic[@"title"];
if ([dic[@"typeID"] integerValue] == 1) {
self.dataArray = [NSMutableArray arrayWithArray:title];
}
if ([dic[@"typeID"] integerValue] == 2) {
self.dataArray = [NSMutableArray arrayWithArray:title];
}
if ([dic[@"typeID"] integerValue] == 3) {
self.dataArray = [NSMutableArray arrayWithArray:title];
}
//刷新表格
[self.testTableview reloadData];
}
// 发送方1
- (void)addNotifiAction{
NSArray *dataArray = @[@"OneView123",@"OneView345",@"OneView678"];
NSDictionary *dic = @{@"title":dataArray,@"typeID":@(1)};
[[NSNotificationCenter defaultCenter] postNotificationName:@"noti" object:nil userInfo:dic];
}
// 发送方2
- (void)addNotifiAction{
NSArray *dataArray = @[@"TwoView12",@"TwoView34",@"TwoView56",@"TwoView78"];
NSDictionary *dic = @{@"title":dataArray,@"typeID":@(2)};
[[NSNotificationCenter defaultCenter] postNotificationName:@"noti" object:nil userInfo:dic];
}
// 发送方3
- (void)addNotifiAction{
NSArray *dataArray = @[@"ThreeView1",@"ThreeView2",@"ThreeView3",@"ThreeView4",@"ThreeView5"];
NSDictionary *dic = @{@"title":dataArray,@"typeID":@(3)};
[[NSNotificationCenter defaultCenter] postNotificationName:@"noti" object:nil userInfo:dic];
}
网友评论