Before executing segue, the program will call the method - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender in sourceViewController (the view controller that calls segue). In this method, you can specify a destinationViewController reference to self:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { [segue.destinationViewController setDelegate:self]; }
Of course, you need a property in destinationViewController:
@property (weak, nonatomic) id<yourProtocol> delegate;
Hope this helps.
source share