지금 바로 FirstviewController에서 버튼을 하나 클릭했습니다. 클릭 할 때 대리자를 사용하여 값을 다시 가져옵니다. 지금 당장이 값을 SecondViewController로 보내고 테이블 뷰 데이터를 다시로드하려고합니다. 그렇게하는 방법? 방법에 대한 nsnotificationcenter를 사용하지만, 노력하고, 그것은 작동하지 않습니다. Firstviewcontroller에서 구현 한 위임에 알림을 게시합니다. 이 같은 코드 :다른 뷰 컨트롤러의 테이블 뷰 데이터를 다시로드하는 방법
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]);
}
안녕하세요, 프로토콜 개념을 사용합니다 ..... –