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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:07:06+00:00 2026-05-31T17:07:06+00:00

(sorry for my english :-) I’m loading a custom UITableViewCell: static NSString *CellIdentifier =

  • 0

(sorry for my english 🙂
I’m loading a custom UITableViewCell:

static NSString *CellIdentifier = @"ReminderCell";
ReminderCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    NSLog(@"Alloco nuova cella");
    NSArray *objectsInNib = [[NSBundle mainBundle] loadNibNamed:@"ReminderCell" owner:nil options:nil];
    for(id currentObject in objectsInNib)
    {
        if([currentObject isKindOfClass:[ReminderCell class]])
        {
            cell = (ReminderCell *)currentObject;
            break;
        }
    }
} //fine caricamento cella dal Nib

return cell;

I’m setting the owner to nil because I have .m and .h for this cell, and want to have the outlet inside it’s own files and not in the UITableViewController. It’s working ok.

My question is about correct memory management in this situation.

I understand that loadNibNamed returns an autoreleased array.
Moreover, I understand that the autorelease pool is drained at the end of the current loop.
For this reason, there should be no need to retain my custom cell before returning it.

But, I’ve heard many times that you shuold assume that an autoreleased object is guaranteed to live only until the end of the method where the autorelease was sent.
Assuming this, I should retain the cell immediately and then autorelease it:

cell = [[(ReminderCell *)currentObject] retain];
//code...
[cell autorelease];
return cell;

Is this correct or should I not worry about this?
Thanks

  • 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-31T17:07:08+00:00Added an answer on May 31, 2026 at 5:07 pm

    This is not necessary. Object is not guaranteed to live only until the end of the method where the autorelease was sent – methods are irrelevant here. Object will be released after autorelease pool to which it was added by autorelease method is drained. Since there is no autorelease pool management in your method currentObject will not receive release during its execution.

    For example (without ARC of course):

    id obj;
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
    ...
    obj = [other object];
    ...
    [pool drain];
    
    [obj doSomething]; // DANGEROUS
    

    In your case it is something like:

    id obj;
    ...
    obj = [other object];
    ...
    [obj doSomething]; // SAFE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for my English. I can't obtain sender name using custom extractor. I'm trying
Sorry ,my English is poor, I have never speak English after I leave the
Sorry for bad English :( Suppose i can preliminary organize recipes and ingredients data
Firstly, sorry for my English (I'm from China). By reading this article( how to
Hi (sorry for my ugly english) I wonder if this is possible to retrieve
Hello (Sorry for my bad English) Is it bad practice to assign object to
Sorry my English is bad. I hope you can get what I want. I
sorry for my english. i use classic asp and try open recordset with following
(sorry for my english) When I add JLabel to Form in Netbeans, I couldn´t
Sorry for my English. I need sort nodes of this XML data <root> <section

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.