In my app I have a tableView with custom cell, this is .h of custom cell
@interface TableViewCell : UITableViewCell{
IBOutlet UILabel *prod;
IBOutlet UIImageView *back;
}
@property (nonatomic, retain) IBOutlet UILabel *prod;
@property (nonatomic, retain) IBOutlet UIImageView *back;
and it’s .m
@implementation TableViewCell
@synthesize prod, back;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void) dealloc{
[super dealloc];
[prod release];
[back release];
}
@end
in my delegate methods of tableView I have this
- (void)tableView:(UITableView *)tableView commitEditingStyle...
but when I delete last row of my tableView I have an EXC_BAD ACCESS here:
- (void) dealloc{
[super dealloc];
[prod release];
[back release]; <-- for this I have a EXC BAD ACCESS
}
why?
You should call
[super dealloc]at the end of yourdeallocmethod.Additionally, as you’ve properties, make use of them. Instead of releasing directly assign
nilto them: