Hey guys,
I’m new to Objective-C, and I’m making an app, and when you click on a table cell it does what it’s supposed to, but when you go back and click on the cell the second time, it crashed with “EXC_BAD_ACCESS”. Could you tell me what it means, and why is it only crashing the second time, and how could I fix it? I’m pretty sure it’s in this function:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
RaceData * data = [self.units objectAtIndex:indexPath.row];
ProtossInfo * info = [[ProtossInfo alloc] initWithNibName:@"ProtossInfo" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:info animated:YES];
info.title = data.titler;
info.minerals.text = data.min;
info.vespene.text = data.vesp;
info.supply.text = data.sup;
info.portrait.image = data.porty;
[info release];
[data release];
}
You’re releasing
data, which you didn’tretain.