I have my tableView connected to a database table. When I tap on a row I push a view with all the details of the item. Every thing works fine.
This is the code in the main class:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailsViewController *detailViewController = [[DetailsViewController alloc] initWithNibName:@"DetailsViewController" bundle:nil];
NSDictionary *rowVals = (NSDictionary *) [shoppingListItems objectAtIndex:indexPath.row];
NSString *titleString = [(NSString *) [rowVals objectForKey:@"item"] autorelease];
NSString *category = [(NSString *) [rowVals objectForKey:@"groupid"] autorelease];
NSNumber *priceNumber = [(NSNumber *) [rowVals objectForKey:@"price"] autorelease];
NSString *priceString = [[priceFormatter stringFromNumber: priceNumber] autorelease];
NSDate *date = [(NSDate *) [rowVals objectForKey:@"dateadded"] autorelease];
NSString *dateString = [[dateFormatter stringFromDate:date] autorelease];
NSNumber *IO = [(NSNumber *) [rowVals objectForKey:@"incout"] autorelease];
detailViewController.stringTitle = titleString;
detailViewController.categoryVar = category;
detailViewController.priceVar = priceString;
detailViewController.dateVar = dateString;
detailViewController.IOVar = IO;
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
and this in the DetailsViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = stringTitle;
nome.text = stringTitle;
prezzo.text = priceVar;
data.text = dateVar;
if ([IOVar isEqualToNumber:[NSNumber numberWithInt:1]]) {
categoria.hidden = NO;
categoriaLabel.hidden = NO;
photoLabel.hidden = NO;
categoria.text = categoryVar;
} else if ([IOVar isEqualToNumber:[NSNumber numberWithInt:0]]){
categoria.hidden = YES;
categoriaLabel.hidden = YES;
photoLabel.hidden = YES;
categoria.text = @"";
}
}
If I push and go back more than 3 times my app crash with EXC_BAD_ACCESS in main.m
Thanks if you read till here, and sorry for my bad english.
That definitely sounds like you're over-releasing an object (aka a 'zombie').
Xcode Instruments is an excellent tool for tracking down zombies.
Read about it here, and give it a go.
http://www.markj.net/iphone-memory-debug-nszombie/
It's much more fun than killing zombies in Call of Duty ;-)
Good luck!