Goal C: How to resolve code leaks (results obtained using the tool)

I ran the tools for my application (which contains a UITableView) and got the following results

The cell will call the [UICustomButton SetButtonWithAnswer ....] method every time the cell becomes visible

EDIT: added more screenshots

enter image description here

enter image description hereenter image description hereenter image description hereenter image description here

The problem is that I'm not sure what exactly is causing the leak. I released all my inits values ​​in code. Why is it still leaking?

Any advice on this would be greatly appreciated!

EDIT:

I added UICustom Buttons as follows

if (cell == nil)
{
    cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease];
    //Add like button
    UICustomButton *likeButton = [[UICustomButton alloc]init];
    likeButton.tag = 7;

    //Add comment button
    UICustomButton *commentButton = [[UICustomButton alloc]init];
    commentButton.tag = 8;

    //Add answer too button
    UICustomButton *answerButton = [[UICustomButton alloc]init];
    answerButton.tag = 9;

    [self.contentView addSubview:likeButton];
    [self.contentView addSubview:commentButton];
    [self.contentView addSubview:answerButton];

    [likeButton release];
    [commentButton release];
    [answerButton release];
}


//Set like button
UICustomButton *thisLikeButton = (UICustomButton *)[self.contentView viewWithTag:7];
[thisLikeButton setButtonWithAnswer:self.answerForCell buttonType:@"like" navcon:self.navcon andFrame:CGRectMake(CELL_TEXT_LEFT_MARGIN, totalCommentLabelHeight + CELL_SPACING*4, 45, CELL_BUTTON_HEIGHT)];
thisLikeButton.imageView.image = [UIImage imageNamed:@"heart.png"];


//Set comment button
UICustomButton *thisCommentButton = (UICustomButton *)[self.contentView viewWithTag:8];
 [thisCommentButton setButtonWithAnswer:self.answerForCell buttonType:@"comment" navcon:self.navcon andFrame:CGRectMake(CELL_TEXT_LEFT_MARGIN + 45 + 5, totalCommentLabelHeight + CELL_SPACING*4, 80, CELL_BUTTON_HEIGHT)];
thisCommentButton.imageView.image = [UIImage imageNamed:@"chat.png"];

//Set answer button
UICustomButton *thisAnswerButton = (UICustomButton *)[self.contentView viewWithTag:9];    
[thisAnswerButton setButtonWithAnswer:self.answerForCell buttonType:@"join in" navcon:self.navcon andFrame:CGRectMake(1.5*CELL_TEXT_LEFT_MARGIN + 45 + 5 + 80 + 5, totalCommentLabelHeight + CELL_SPACING*4, 60, CELL_BUTTON_HEIGHT)];
thisAnswerButton.imageView.image = [UIImage imageNamed:@"beer-mug_white.png"];
+3
source share
3 answers

alloc/init setButton:… . , .

if (self.imageView == nil) {
  UIImageView tempImageView = alloc/init …
  self.imageView = tempImageView;
  [tempImageView release];
}

self.imageView.image = self.image;

+2

, "", "" ""? , : , cell = nil. UITableView , .

? , ?

, : answerForCell, navcon answer.likers: - ?

+2

it may be lower, but I do not see tempLabelwhich will be released. You really have to tell us what's going on. You should be able to determine if this is an ImageView, label, etc.

+1
source

All Articles