I am having an argument with my team member regarding popToViewController.
For me best approach is Can i pop to Specific ViewController?
But he think we should create a static instance of the viewController and then call
-(void)takeToPreviousViewController {
if([IVPreviousViewController sharedInstance]) {
[self.navigationController popToViewController:[IVPreviousViewController sharedInstance] animated:YES];
}
}
I strongly appose this approach because we're creating a public method in IVPreviousViewController which has no relation to the currentViewController. We should always avoid method expose like this.
Can anyone point me a solid reason about the best approach.
Update:
IVPreviousViewController.h
__weak static IVPreviousViewController * staticEventDetailViewController;
+(IVPreviousViewController *)sharedInstance;
IVPreviousViewController.m
+(IVPreviousViewController *)sharedInstance {
return staticEventDetailViewController;
}
Reason of this approach - On a particular use case in our viewController it has to popbackto IVPreviousViewController