Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6377149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:50:04+00:00 2026-05-25T01:50:04+00:00

i have a problem with my app crashing when my custom TableViewCell gets released.

  • 0

i have a problem with my app crashing when my custom TableViewCell gets released.

the Cell gets initialized like the following in cellForRowAtIndexPath:

SearchTableViewCell *cell = (SearchTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[SearchTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}

cell.nameLabel.text = @"some text";
cell.addressLabel.text = @"some more text";

the cell class itself looks like this

#import <UIKit/UIKit.h>

@class EGOImageView;

@interface SearchTableViewCell : UITableViewCell {
    UILabel *nameLabel;
    UILabel *addressLabel;
    EGOImageView *imageView;
}

@property (nonatomic, retain) UILabel *nameLabel;
@property (nonatomic, retain) UILabel *addressLabel;

- (UILabel *)labelWithColor:(UIColor*)color selectedColor:(UIColor*)selectedColor fontSize:(CGFloat)fontSize bold:(BOOL)bold frame:(CGRect)rect;
- (void)setThumb:(NSString*)thumb;

@end

.m

#import "SearchTableViewCell.h"
#import "EGOImageView.h"

#import "UIView+Additions.h"

@implementation SearchTableViewCell

@synthesize nameLabel = _nameLabel, addressLabel = _addressLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {

        // Initialization code
        UIView *myContentView = self.contentView;

        // Name
        _nameLabel = [self labelWithColor:[UIColor blackColor] selectedColor:[UIColor whiteColor] fontSize:16.0f  bold:YES frame:CGRectMake(140.0f, 16.0f, 181.0f, 21.0f)];
        [myContentView addSubview:_nameLabel];
        [_nameLabel release];


        // Adress
        _addressLabel = [self labelWithColor:[UIColor blackColor] selectedColor:[UIColor whiteColor] fontSize:13.0f  bold:YES frame:CGRectMake(140.0f, _nameLabel.bottom, 181.0f, 21.0f)];
        [myContentView addSubview:_addressLabel];
        [_addressLabel release];


        // Image
        imageView = [[EGOImageView alloc] initWithPlaceholderImage:[UIImage imageNamed:@"placeholder.png"]];
        imageView.frame = CGRectMake(9.0f, 9.0f, 120.0f, 80.0f);
        [myContentView addSubview:imageView];
        [imageView release];

    }
    return self;
}

- (UILabel *)labelWithColor:(UIColor*)color selectedColor:(UIColor*)selectedColor fontSize:(CGFloat)fontSize bold:(BOOL)bold frame:(CGRect)rect {

    UIFont *font;
    if(bold) {
        font = [UIFont boldSystemFontOfSize:fontSize];
    } else {
        font = [UIFont systemFontOfSize:fontSize];
    }

    UILabel *label = [[UILabel alloc] initWithFrame:rect];
    label.backgroundColor = [UIColor clearColor];
    label.textColor = color;
    label.highlightedTextColor = selectedColor;
    label.font = font;

    return label;
}


- (void)setThumb:(NSString*)thumb {
    imageView.imageURL = [NSURL URLWithString:thumb];
}

- (void)willMoveToSuperview:(UIView *)newSuperview {
    [super willMoveToSuperview:newSuperview];

    if(!newSuperview) {
        [imageView cancelImageLoad];
    }
}

- (void)dealloc {
    [_addressLabel release];
    [_nameLabel release];
    [imageView release];
    [super dealloc];
}

@end

does anybody have an idea why my app crashes on releasing such a cell? commenting out the 2 labels and the image view on dealloc method, the app doesn’t crash, but then there will be a memory leak right?

thanks for all hints! please leave a comment if something is unclear!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:50:05+00:00Added an answer on May 25, 2026 at 1:50 am

    imageView is being released twice, once when it is created:

    imageView = [[EGOImageView alloc] initWithPlaceholderImage:[UIImage imageNamed:@"placeholder.png"]];
    imageView.frame = CGRectMake(9.0f, 9.0f, 120.0f, 80.0f);
    [myContentView addSubview:imageView];
    [imageView release];
    

    and once in dealloc:

    - (void)dealloc {
        [_addressLabel release];
        [_nameLabel release];
        [imageView release];
        [super dealloc];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an odd problem that is crashing my app, that I would like
I have been trying to fix this problem for hours. My app keeps crashing
I have this problem of my app crashing (only when press a certain UIButton)
I have a problem with my App for iPhone. Enviroment: I have a TableView,
I have a curious problem: My app is distributed through ClickOnce. I recently installed
I have problem in declaring the intents on my app. I have a form
I have problem with Timeout, when I run a command through app, a timeout
I'm writing an app in Visual Studio C++ and I have problem with assigning
I'm developing small FTP upload app. for mac (10.6 if it matters) Have problem
I have big problem when I am trying to deploy my app over clickonce.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.