您可以使用通知或协议。
使用通知:
在完成保存数据之后和从方法返回之前发布通知。像这样的东西:
// 发布通知 [[NSNotificationCenter defaultCenter] postNotificationName:@"DataSaved" object:nil];
在处理表的控制器中,实现
- (void) dataSaved:(NSNotification *)notification{
[self.tableView reloadData];
}
并在其viewDidLoad
方法中添加以下代码以注册通知:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(dataSaved:)
name:@"DataSaved" object:nil];
最后,在dealloc方法中取消注册添加
[[NSNotificationCenter defaultCenter] removeObserver:self];
使用协议:
开始使用您以前的控制器可以使用的回调创建协议。
@protocol dataSavedDelegate
-(void)dataSaved;
@end
完成数据保存后:
[(id< dataSavedDelegate >)object dataSaved];
现在,在您以前的控制器中,您处理委托方法:在dataSaved()
您重新加载表的方法中。