The question
I'm working on a iOS
app and i have 3 consecutive ViewControllers
:
TableViewController
--> DetailViewController
--> ImageViewController
I perform de forward Segue with a button (Just control drag on Storyboard
) and to go back I have a custom back button with
[self.navigationController popViewControllerAnimated:YES];
To send data forward I use
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
[segue.destinationViewController someFunction];
}
To send data to the parent ViewController
I can use prepareForSegue
in the DetailViewController
, but it doesn't work in the ImageViewController
and there I have to use Notifications
.
It's OK if I use prepareForSegue
to send data with popViewControllerAnimated
?
Should I use Notifications in both cases?
Some code
What I have in the DetailViewController
is a button that perform the Segue to the ImageViewController (just control drag on Storyboard
) and a Back Button with:
- (IBAction)backAction:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
and then the function:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([segue.identifier isEqualToString:@"forwardSegue"]) {
[segue.destinationViewController someFuntionToImageViewController];
} else {
[segue.destinationViewController someFuntionToParentViewController];
}
}
I noticed that I can't assign a segue.identifier to the popViewController
action.