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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:17:39+00:00 2026-05-18T12:17:39+00:00

I wonder if someone could quickly help me with the following, do I need

  • 0

I wonder if someone could quickly help me with the following, do I need to add a [myTableView release]; after I call [view addSubview:[self myTableView]]; ? Initially I was thinking no, and running it through CLANG produced to memory warnings

Here is my thinking:

  • [self setMyTableView:tempTableView]; retainCount = (+1)
  • [view addSubview:[self myTableView]]; retainCount = (+2)
  • //[myTableView release]; << HERE retainCount = (+1)
  • -dealloc [myTableView release]; retainCount = ( 0)

.

@property (nonatomic, retain) UITableView *myTableView;

.

- (void)loadView {
    NSLog(@"%s", __PRETTY_FUNCTION__);

    [self setTitle:@"Location Data"];
    CGRect viewFrame = CGRectMake(0, 20, 320, 460);
    UIView *view = [[UIView alloc] initWithFrame:viewFrame];

    CGRect tableFrame = CGRectMake(0, 0, 320, 416);
    UITableView *tempTableView = [[UITableView alloc] initWithFrame:tableFrame];
    [self setMyTableView:tempTableView];
    [tempTableView release];

    [view addSubview:[self myTableView]];
    //[myTableView release]; << HERE

    [[self myTableView] setDelegate:self];
    [[self myTableView] setDataSource:self];

    [self setView:view];
    [view release];
}

.

- (void)dealloc {
    [myTableView release];
    [dataModel release];
    [super dealloc];
}

EDIT: hmm maybe I don’t as [view addSubview:[self myTableView]]; retains it and will release when done. Your right Carl, my bad. I was getting confused with: alloc, set, release, when this is simply the view taking ownership (and the responsibility to release that later)

  • 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-18T12:17:40+00:00Added an answer on May 18, 2026 at 12:17 pm

    You’re right when you say that [view addSubview:[self myTableView]]; will retain your table view, but since it’s the view who is retaining it, it’s the view that is supposed to release it. And it will, when the view gets dealloc’ed. You only have to release what you retained yourself, i.e., you only have to release the table view once in your dealloc method.

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

Sidebar

Related Questions

I wonder if someone could tell me how to make it possible to move
I have something like this $.ajaxSetup({ cache: false }); I am wonder can you
Now this is going to be a little weird use-case. Maybe someone has some
Recently I've learned the wonder of indexes, and performance has improved dramatically. However, with
I am trying to get jscrollpane working on a very simple page, but for
This is a real n00b question but i am very new at this and
I am testing this JQuery plugin Tag-it by Levy Carneiro in my ASP MVC
I'm currently working on some quite old C++ code and often find things like
I'm thinking of adding a queue function in a product based on a bunch
The Issue Just to give you some background, I'm currently enrolled as a student

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.