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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:31:03+00:00 2026-06-01T10:31:03+00:00

I am creating a Table View in viewDidAppear, because my app requires it to

  • 0

I am creating a Table View in viewDidAppear, because my app requires it to be created here for multiple reasons. However I notice that I get a memory leak when I analyze my application.

I thought using the instance variable _tableView is not a good idea in any other method besides init and dealloc. Should I just use autorelease, I want to make sure the table gets released at the appropriate time.

There is a property for my Table View.

@property (nonatomic, retain) UITableView *tableView;

And I create the Table View as such:

- (void)viewDidAppear:(BOOL)animated
{
    self.tableView = [[UITableView alloc]
                      initWithFrame:CGRectMake(0, 0, 320, 300) 
                      style:UITableViewStyleGrouped];

    // Table View properties
    self.tableView.dataSource = self;
    self.tableView.delegate = self;

    [self.view addSubview:self.tableView];
}

- (void)viewDidDisappear:(BOOL)animated
{
    self.tableView = nil;
}

- (void)dealloc
{
    [_tableView release];
}
  • 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-06-01T10:31:05+00:00Added an answer on June 1, 2026 at 10:31 am

    Autorelease. You get one retain for the alloc and another for the property assignment (assuming it’s a retained property).

    Your dealloc should handle one and an autorelease the other.

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

Sidebar

Related Questions

here is my app. how to add table view or grids in the following.
I’m currently creating an iOS app that uploads files to a server. As multiple
I'm writing a quick simple table view app. I've declared the view I'm creating
While creating a custom iOS table view cell, I created a new .xib file,
I'm working on creating a grouped table view. The data is being loaded alright,
I am creating a table for an application that handles scheduling and deals with
I'm creating custom table view cells, but result is incorrect. My code: - (UITableViewCell
I am creating a table view with UITextField s dynamically. l_textField = [[UITextField alloc]
I am creating the table in the loadView method because I need to resize
I have been going through and re-creating Apple's Advanced Table View Cells example to

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.