My iphone program has a Xib view with a tableview dropped in. I've subclassed UITableViewController and am trying to make the UITableView in the xib send it messages. The program crashes when I touch a tableview row.
It properly calls:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{}
and the cell.textLabel.text is assigned properly.
Interface snippet:
@interface PlayersDrawsViewController : UIViewController {
UITableView *uitableView;
PlayersToDrawTableViewController *pvc;
}
@property (nonatomic, retain) IBOutlet UITableView *uitableView;
@property (nonatomic, retain) IBOutlet PlayersToDrawTableViewController *pvc;
Implementation snippet:
- (void)viewDidLoad
{
// Setup TableView
if (pvc == nil) {
pvc = [[PlayersToDrawTableViewController alloc]
initWithNibName:@"PlayersToDrawTableViewController" bundle:nil];
/* works great, loads rows */
self.uitableView.dataSource = pvc.tableView.dataSource;
/* EXC_BAD_ACCESS when didSelectRowAtIndexPath is called */
//self.tableView.delegate = pvc;
}
}
My UITableViewController Subclass:
@interface PlayersToDrawTableViewController : UITableViewController
<UITableViewDelegate>
{
}
@end
How can I get the delegate hooked up so it doesn't crash sending messages?
I've read these threads and either I'm dense or they don't answer my question:
UITableView issue when using separate delegate/dataSource
UITableView superClass for delegate?
Getting “EXC_BAD_ACCESS” when accessing instance variable from within UITableView delegate method
EXEC_BAD_ACCESS
indidSelectRowAtIndexPath
, you should probably add that code here. – Deepak Danduprolu