I’m working on a project for iOS5 using xcode.
ARC is ON
Using the storyboard
I have a class named Event which contains event info.
I have a TableView on the storyboard linked to my ListViewController.m file
I also made a view on the storyboard called ‘Detail’ and a DetailViewController.m file (which it is linked to)
Currently in my ListViewController.m I used this function:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
[self.navigationController pushViewController:detail animated:YES];
}
The items in the listview are made up from a var from the listviewcontroller, named events.
What I want to do is when I init the detailview, I want to pass the event coupled to that list item with it so I can fill up the text from the labels with the correct information in my DetailViewController.m.
I would like to do it like this cause I will also have other representations for the events (on a map, …) and would like to use this detail view for all of them.
How to best set this up?
Add an ‘Event’ property on your ‘DetailViewController’ and assign it to the controller before doing the push:
Then you can use it to put the text to the labels.