通知
当B 完成事件之后,让B vc发送通知给A vc
在A vc 中注册通知和实现通知
注册
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rePostData:) name:@"isPost" object:nil];
实现
// 当发帖完成之后刷新数据
- (void)rePostData:(NSNotification *)sender {
NSString *userid = [[NSUserDefaults standardUserDefaults]objectForKey:@"userid"];
// 获取文件访问的路劲
NSString *path = [NSString stringWithFormat:@"%@api/comments/MessageList",testHttp];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"keyword"] = @(self.keyword);
params[@"userid"] = userid;
params[@"page"] = @1;
[self.manager POST:path parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self.SocialDataList insertObject:[MessageModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"]][0] atIndex:0];
[self.myTableView reloadData];
[self.myTableView.mj_header endRefreshing];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self.myTableView.mj_header endRefreshing];
self.myTableView.mj_footer.hidden = YES;
}];
}
发送通知
当B完成操作之后 在B vc中发送通知
[[NSNotificationCenter defaultCenter]postNotificationName:@"isPost" object:nil];
网友评论