I’m facing issue with redirecting the viewControllers using pop/pushViewControllers. I’ve three view controller like below image –

In my 3rd view i’ve some ToggleButton based on that toggleButton the data which is in 2nd View will change. After, changing something on 3rd view and press Done button in my 3rd View i just started my 2nd ViewController using pushViewController And, the changes are occured successfully.
But, what was the issue is, when i try to press the back button on my 2nd view page its redirecting me again to 3rd viewController (Because of pushViewController)
I try to start my 2nd view using popViewController but, its giving exception.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.
I’ve used below code –
SecondViewController *second = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
second.array = resultArray;
second.indexValue = ind;
[self.navigationController popToViewController:second animated:YES];
How do i solve this issue? Any idea?
From 3rd viewcontroller you just need to call this method to pop to 2nd viewcontroller :
EDIT :
For notifying the second vc for data change you can use delegate. Follow this :
On ThirdViewController.h
And before pushing the thridVC from secondVC assign secondVC as the delegate of thirdVC :
and in SecondViewController.m