I suggest you call the delegate method after loading the view. Set the delegate as controller B. and after viewDidLoad (in controller A) is completed, call the delegate method. You can even pass parameters as you wish to the delegate.
Here is a sample code:
Controller B:
a.delegate = self; [b.navigationController pushViewController:a animated:YES];
Implement delegate method:
- (void)controllerIsLoaded:(ControllerA *)controllerA status:(NSString *)status { a.status = status; }
Controller Ah File:
@class ControllerA; @protocol ControllerADelegate <NSObject> - (void)controllerIsLoaded:(ControllerA *)controllerA status:(NSString *)status; @end @interface ControllerA : UIViewController @property (nonatomic, weak) id <ControllerADelegate> delegate;
Am file controller:
- (void)viewDidLoad:(BOOL)animated { [super viewDidLoad:animated]; if ([_delegate respondsToSelector:@selector(controllerIsLoaded:status)]) [_delegate controllerIsLoaded:self status:@"Loaded"]; }
Lirik source share