現在,在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]);
}
嘿使用協議概念..... –