现在,在FirstviewController中,我得到一个按钮,当我点击它时,我使用委托返回值。现在,我想将此值发送到SecondViewcontroller并重新加载它的tableview数据。怎么做?如何使用nsnotificationcenter,但我已经尝试过,它不工作。我将通知发布到Firstviewcontroller中实现的委托中。这样的代码:如何重新加载另一个视图控制器的tableview数据
FirstviewController.m
// delegate that get selected cat
- (void)didSelectSubCat:(SubCat *)cat;
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"DidSelectCat" object:self userInfo:@{@"catId": cat.catId}];
}
SecondViewcontroller.m
- (void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectedCat:) name:@"DidSelectCat" object:nil];
}
- (void)selectedCat:(NSNotification *)notif
{
NSLog(@"userinfo: %@", [notif userInfo]);
}
嘿使用协议概念..... –