This question already has an answer here:
- objective C underscore property vs self 4 answers
In my VC I have declared a custom delegate property:
@interface VC2 : BaseVC
@property (nonatomic,weak) id<VC2Delegate> delegate;
@end
and from VC1, I'm setting this delegate:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString: @"VC2"]) {
self.VC2 = [segue destinationViewController];
[self.VC2 setDelegate:self];
}
}
and in my VC2, I have written a setter method for the delegate:
-(void)setDelegate:(id)del{
self.delegate=del;
}
The issue, after the pprepareForSegue method call in VC1, the setter method for delegate in VC2 gets called so many times and my apps get crashed. I'm not sure what could be the reason.
Here is the satcktrace:
I don't have any implementation my BaseVC. It's just a plain VC.