I have a MainWindow class that is built from a nib and set up as follows:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
MainViewController *mainView = [[MainViewController alloc] initWithNibName:@"MainViewController"
bundle:nil];
if(!mainView)
{
return;
}
naviController = [[UINavigationController alloc] initWithRootViewController:mainView];
[naviController setToolbarHidden:YES];
[[naviController navigationBar] setTintColor:[UIColor blackColor]];
[[naviController toolbar] setTintColor:[UIColor blackColor]];
[self.window setRootViewController:naviController];
[self.window makeKeyAndVisible];
}
This works and correctly displays the MainViewController, but when I try to scroll down in the MainViewController‘s table view it throws an EXC_BAD_ACCESS. Apparently UIKit is referring to a second MainViewController that was built in [self.window makeKeyAndVisible]; I can’t figure out why it is referencing that over the one I passed into initWithRootViewController:mainView.
Here are the two MainViewControllers. The first one I initialize, the second is created in makeKeyAndVisible.

Here is the second MainViewController being called as a zombie.

Any ideas on why this is happening?
As requested:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MainViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainViewCell"];
int i = [indexPath row];
NSLog(@"%d\n",i);
if (cell == nil) {
// Create a temporary UIViewController to instantiate the custom cell.
UIViewController *temporaryController = [[UIViewController alloc] initWithNibName:@"MainViewCell" bundle:nil];
// Grab a pointer to the custom cell.
cell = (MainViewCell *)temporaryController.view;
// Release the temporary UIViewController.
[temporaryController release];
}
[[cell icon] setImage:[UIImage imageNamed:[[moduleXMLList objectAtIndex:i] objectForKey:@"thumbnail"]]];
[[cell title] setText:[[moduleXMLList objectAtIndex:i] objectForKey:@"title"]];
[[cell description] setText:[[moduleXMLList objectAtIndex:i] objectForKey:@"description"]];
return cell;
}
The problem was that I was using File’s Owner as a MainViewController while having a second UIViewController under Objects. This is wrong, and so once I got rid of the Object and just used File’s Owner it worked like a charm.