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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:13:21+00:00 2026-05-16T01:13:21+00:00

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellId]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@ThemeCell owner:self

  • 0
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellId];
if (cell == nil) 
    {
    [[NSBundle mainBundle] loadNibNamed:@"ThemeCell" owner:self options:nil];
        cell = self.themeCell;
        self.themeCell = nil;
}
...
return cell;

My understanding is that self.themeCell = nil; should destroy the object since there is no longer any owner of it. cell = self.themeCell doesn’t retain it, but just assigns it. So what keeps the cell alive? I can only assume that the synthesized property is autoreleasing the old value instead of releasing it immediately. Is this the case?

  • 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-16T01:13:22+00:00Added an answer on May 16, 2026 at 1:13 am

    The nib loading process is slightly (but not very) complicated, and differs between the OSX and iPhone platforms. You can read about this in the Nib Object Life Cycle section of the Resource Programming Guide. In table 1-1 you will find this:

    Objects in the nib file are created
    with a retain count of 1 and then
    autoreleased. As it rebuilds the
    object hierarchy, however, UIKit
    reestablishes connections between the
    objects using the setValue:forKey:
    method, which uses the available
    setter method or retains the object by
    default if no setter method is
    available

    So what happens is that the cell is created with a retain count of 1, and then when it is set with your synthesized setter, that it increased to 2. When you set your property to nil the retain count goes down to 1, and the cell is returned to the table view. The table view adds it to its view hierarchy, and thereby retains it (and maybe retains it in other parts of its logic as well). After all this, the autorelease pool is drained.

    I can only assume that syntesized
    property is autoreleasing the old
    value instead of release, is this the
    case?

    No, synthesized setters release the object immediately. (Although some framework classes might hold on to the object a bit longer, if it’s a view that needs to be animated out for example.)

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

Sidebar

Related Questions

This is my cellForRowAtIndexPath UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc]
static NSString *CellIdentifier = @Cell; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@]; if (cell == nil)
Using storyboard, static cells, in cellForRowAtIndexPath: the line UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; always
In one part of my code, i call UITableViewCell *cell = (UITableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath];
I put a UIProgressView on a UITableViewCell, like that: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@downloadcell];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { self.cellIdentifier = [self.brain returnCellIdentifier:indexPath]; UITableViewCell *cell =
dequeueReusableCellWithIdentifier: Returns a reusable table-view cell object located by its identifier. (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier
I was calling UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; from -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath in
This - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (cell.accessoryType

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.