IOS: bloqueo extraño para una vista de imagen

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
}

¿por qué?

preguntado el 31 de julio de 12 a las 10:07

If prod y back are created from a xib (Interface Builder), they can be weak references I think (already retained by parent view, i.e. main view). Correct me if I'm wrong... -

Did you try enabling zombies? When are prod y back set, and to what values? -

1 Respuestas

Deberías llamar [super dealloc] al final de tu dealloc método.

Additionally, as you've properties, make use of them. Instead of releasing directly assign nil a ellos:

- (void)dealloc
{
    self.prod = nil;
    self.back = nil;
    [super dealloc];
}

Respondido 31 Jul 12, 10:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.