ios - How to pass delegate between ViewControllers -
i have 3 view controllers. let's call them basevc, firstvc , secondvc. firstvc presented modally basevc. secondvc pushed firstvc. there 1 button on each firstvc , secondvc. clicking them, want dismiss current vc , let basevc something. created protocol, let basevc obey it, , set basevc firstvc's delegate. when set secondvc's delegate firstvc, breakpoint show succeeding. when call delegate secondvc, shows _delegate nil.
is because delegate weak
property? how pass delegate between view controllers or there other way solve problem?
you can use postnotification while dismissing vc , add observer on basevc operation.
you use [self.navigationcontroller dismissviewcontrolleranimated:yes completion:nil];
in button action dismiss view controller.
before need post notification [[nsnotificationcenter defaultcenter] postnotificationname:@"notificaitonbasevc" object:nil];
, add observer in basevc's viewdidload method follows
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(dosomeoperation:) name:@"notificaitonbasevc" object:nil];
Comments
Post a Comment