Reputation: 2736
I use multiple storyboards in an XCode project. There are multiple view controllers on each of the storyboards. Using prepareForSegue to transition between view controllers on different storyboards works fine but what is the best way to pass data between the view controllers on different storyboards.
For example, how can I pass parameters/data from ViewController1 on storyboard1 to ViewController2 on storyboard2?
Upvotes: 0
Views: 329
Reputation: 23233
In your segue, you get access the destinationViewController
which is the view controller are about to load. You can use this reference to set any data you desire.
This is an example of passing selected cell data from a UITableView
to the destinationViewController
.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showNoticeDetails"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
[segue.destinationViewController setNotice:[notices objectAtIndex:indexPath.row]];
}
}
Upvotes: 2