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

  • Home
  • SEARCH
  • 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 7589063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:04:28+00:00 2026-05-30T20:04:28+00:00

I have a custom cell which has two UILabel objects. //AppEventCell.h #import <UIKit/UIKit.h> @interface

  • 0

I have a custom cell which has two UILabel objects.

//AppEventCell.h
#import <UIKit/UIKit.h>

@interface AppEventCell : UITableViewCell
{
    UILabel * titleLabel;
    UILabel * periodLabel;
}
@property (nonatomic, retain) UILabel * titleLabel;
@property (nonatomic, retain) UILabel * periodLabel;
@end


//AppEventCell.m
#import "AppEventCell.h"

@implementation AppEventCell
@synthesize titleLabel, periodLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 13, 275, 15)];
        [self.contentView addSubview:titleLabel];

        periodLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 33, 275, 15)];
        [self.contentView addSubview:periodLabel];
    }
    return self;
}
@end


- (AppEventCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"NoticeTableCell";

    AppEventCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {

        cell = [[AppEventCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    [cell.titleLabel setText:((NSString *)[[listArray objectAtIndex:indexPath.row] valueForKey:KEY_TITLE])];

[cell.periodLabel setText:((NSString *)[[listArray objectAtIndex:indexPath.row] valueForKey:KEY_PERIOD])];

return cell;

}

Here’s a question. Where Should I release titleLabel and periodLabel? I think I should release them by myself. However, there is no dealloc() in AppEventCell(I created the method but it never called). I put the release in CellForRowAtIndexPath but error occured when cell reused.

Shouldn’t I release the objects?

  • 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-30T20:04:29+00:00Added an answer on May 30, 2026 at 8:04 pm

    1) Here you should release labels after adding them as subviews:

    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 13, 275, 15)];
            [self.contentView addSubview:titleLabel];
            [titleLabel release];
    
            periodLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 33, 275, 15)];
            [self.contentView addSubview:periodLabel];
            [periodLabel release];
        }
        return self;
    }
    

    2) dealloc method should be called for your cells. It’s wrong that it is not called. Check if you are releasing your tableView and in - (AppEventCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    is another memory leak:

    cell = [[[AppEventCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    

    Mark new cell as autoreleased object.

    3) If cell is reused ([tableView dequeueReusableCellWithIdentifier:CellIdentifier];) then you should call release or autorelease.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom UITableView cell which has a button and a label. I
I have a custom UITableViewCell which is part of a navigation controller. The cell
I have a custom UITableViewCell which has some subviews. i.e. some labels, some images.
I have a custom table cell class. TextInput.h @interface TextInput : UITableViewCell <UITextFieldDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate> {
I have a custom UITableViewCell subclass. I have set the contentView of my cell
I have a custom subclass of a UITableViewController which has a editable cells in
I have a custom table cell which contains a number of UILabels. At runtime,
I am making a custom cell which has text fields and as a result
i am having a tableview in which custom cells are loaded.Custom cell has a
In my app, I have a UITableView which has some custom cells and in

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.