Quote:
Originally Posted by chings228
finally i found that a code which will make the program crash , but i have no idea what's wrong
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
DataDetail *detailViewController = [[DataDetail alloc] initWithNibName:@"DataDetail" bundle:nil];
// ...
// Pass the selected object to the new view controller.
//NSString *textTemp = [NSString stringWithFormat:@"%@",[viewArray objectAtIndex:[indexPath row]]];
detailViewController.message = [viewArray objectAtIndex:indexPath.row];
message has been declared at datadetail.h already
but if i add this
detailViewController.title = textTemp
// the program will crash when i back to the table view immediately
// but the title show properly at datadetail.nib .
//[textTemp release];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
|
i notice that this line is missing:
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
and perhaps it should be more like this:
DataDetail *aDetail = [self dataDetailForIndexPath:indexPath];
DetailViewController *detailController = [[DetailViewController alloc] init];
detailController.detail = aDetail;
[self.navigationController pushViewController:detailController animated:YES];
[detailController release];