tags:

views:

91

answers:

2

Right now I have an indexed tableview that goes to a detail view but i want it to go to another tableview then a detail view.

my code like this:

` - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

displyAnnController *anController = [[displyAnnController alloc] initWithNibName:@"AnnView" bundle:[NSBundle mainBundle]];

DetailViewController *dvController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];

switch (indexPath.row) {
    case 0:
        [self.navigationController pushViewController:anController animated:YES];
        [anController release];
        anController = nil;
        break;
    case 1:
        [self.navigationController pushViewController:dvController animated:YES];
        [dvController release];
        dvController = nil;
        break;
    default:
        break;
}`

and when I press the cell with index 0 in the simulator, the program is crash!

what's the problem? pleas help me ..

A: 

View the debug console (Cmd-Shift-R) and see what the error is.

Are you overriding the -initWithNibName message on displyAnnController? Or the -viewDidLoad message?

You also have a memory leak. You always +alloc both controllers, but only -release one of them. Don't +alloc your controller unless you are going to actually use it.

Brannon
Asad Khan
A: 

No, I didn't override the -initWithNibName, I just use it as the same way here,but to push to ControlView NOT TableView.Also,no errors in debug console. and I have tried to release the controllers after the switch block, but the program still crash :( anyway, it's work when I write:

displyAnnController *anController = [[displyAnnController alloc] initWithStyle:UITableViewStyleGrouped]];

instead of :

displyAnnController *anController = [[displyAnnController alloc] initWithNibName:@"AnnView" bundle:[NSBundle mainBundle]]

Temporarily, I accept this just to complete my work! but I hope to find any help example because no need to be as group.

thanx all for help and recommendations.

Rona