Why is DetailViewController Table View empty?

What have I been up to lately? I have been immersing myself into programming. iOS development to be exact. The one way I have found to be fully engaged in learning software development is to solve a problem that you are passionate about. In this instance it’s an app that I find may solve an immediate issue of mine. iOS development demands a great bit of time to get familiar with especially with the fact that I have been away from any serious programming since 2004-’05. This past October I have dedicated myself to learning and being as consistent as possible with iOS Dev. Since thinking about this app and working on its creation the process has been fun. Today I solved one of the many bugs/issues I’ve faced in building the app.

I am using iOS 5 and Xcode 4.2. In iOS 5 storyboards was introduced. Storyboard helps better the UI creation process. So I came across an issue where my DetailViewController object was not being properly instantiated in search. I have been trying to solve this for the last week or so. Today I finally read over the View Controller Guide Apple documentation and realized that if you attempt to initialize a view controller while using segue (a feature of storyboard) you do not get the behavior that you’re hoping for in your view controller. So with the guides help I fixed this issue in the code below.

– (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

if (tableView == self.searchDisplayController.searchResultsTableView)

{

if (!self.detailViewController) {

UIStoryboard *storyboard = self.storyboard;

self.detailViewController = [storyboard instantiateViewControllerWithIdentifier:@”DetailViewController”];

}

self.detailViewController.project = [self.dataController.filteredListContent objectAtIndex:indexPath.row];

[[self navigationController] pushViewController:self.detailViewController animated:YES];

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s