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 3596788
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:02:02+00:00 2026-05-18T20:02:02+00:00

I just added some code that was taken from the Apple docs which shows

  • 0

I just added some code that was taken from the Apple docs which shows how to use custom UITableViewCells that are created from a nib. I’m new to iOS development, so I’m still learning about proper memory management and the code isn’t exactly clear to me as to how it works in the first place. When I run the Allocations instrument, it shows unallocated memory in the code below. Specifically, it shows the UITableViewCells remain alive after the view controller is popped off the nav stack…

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"MyCustomCell_iPhone" owner:self options:nil];  //<--Allocations instrument complaining about this line
        cell = customCell;
        [self setCustomCell:nil];
    }

    return cell;
}

customCell is an instance var defined in this view controller, like so…

IBOutlet UITableViewCell *customCell;
@property (nonatomic, retain) IBOutlet UITableViewCell *customCell;

Is there a problem in this code?

Thanks so much for your wisdom!

  • 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-18T20:02:03+00:00Added an answer on May 18, 2026 at 8:02 pm

    I compared the code from the documentation:

    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil];
        cell = tvCell;
        self.tvCell = nil;
    }
    

    With your code:

    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"MyCustomCell_iPhone" owner:self options:nil];
        cell = [self customCell];
        [self setCustomCell:nil];
    }
    

    There seems to be a disparity at the line where you assign cell. Apple’s example code uses tvCell, the instance variable, whereas you use [self customCell], the property getter for the instance variable. Could that be the cause? Try changing

        cell = [self customCell];
    

    to

        cell = customCell;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just added some code that was taken from the Apple docs which shows
I have added some code which compiles cleanly and have just received this Windows
We just added an autoupdater in our software and got some bug report saying
I'm code reviewing a change one of my co-workers just did, and he added
I'm using the PageControl project, which is on Apple's dev site. I've added a
I am using asp.net mvc for an application. I've taken some guidance from Rob
I have the following code example taken from the code of a Form :
I came across some code the other day and I wondered if that was
I just added xUnit to our test project (for the Asserts, we're still using
I just added printing capability to a web site using a style sheet (ie.

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.