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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:10:36+00:00 2026-05-30T01:10:36+00:00

Just have a quickly question (more of a curiosity thing) based on a problem

  • 0

Just have a quickly question (more of a curiosity thing) based on a problem I just solved (I will post the answer to my problem in the post, which can be found here: My former question

The thing is that I have this UITableView which contains custom cell objects. Every time you enter this view, I generate new cells for the UITableView like this:

    if (cell == nil)
{
    [[NSBundle mainBundle] loadNibNamed:@"UploadCellView" owner:self options:nil];

    cell = customCell;
}

Which happens in the standard method:

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

Now the problem is that my custom cell objects listens for NSNotifications about upload objects happening in the background, so they can update its model data to their labels and progress bars etc. It happens like this (this is a method from the custom cell objects):

-(void) uploadProgress: (NSNotification*)notification
{
NSDictionary *userInfo = [notification userInfo];

NSNumber *uploadID = [userInfo valueForKey:@"uploadID"];

if (uploadID.integerValue == uploadActivity.uploadID)
{
    UIProgressView *theProgressBar = (UIProgressView*)[self viewWithTag:progressBarTag];

    [theProgressBar setProgress:(uploadActivity.percentageDone / 100) animated:YES];

    UILabel *statusText = (UILabel*)[self viewWithTag:percentageTag];

    [statusText setText:[NSString stringWithFormat:@"Uploader - %.f%% (%.01fMB ud af %.01fMB)", uploadActivity.percentageDone, uploadActivity.totalMBUploaded, uploadActivity.totalMBToUpload]];
}
}

When an upload finish they simply do this:

-(void) uploadFinished: (NSNotification*)notification
{
NSDictionary *userInfo = [notification userInfo];

NSNumber *uploadID = [userInfo valueForKey:@"uploadID"];

if (uploadID.integerValue == uploadActivity.uploadID)
{        
    [self setUploadComplete];

    [[ApplicationActivities getSharedActivities] markUploadAsFinished:uploadActivity];

    NSLog(@"BEGINNING RELOAD");
    [parentTable reloadData];
    NSLog(@"ENDING RELOAD");
}
}

Now the problem is when they call their owning tableview. When the view which the tableview is contained within dismisses, the old custom cell objects are still alive in the background getting NSNotfications. And when that upload is then done, the old custom cell objects from the former table views still tries to call that parentTable property which was set at that time, now resulting in calling random junk memory.

The way I solved this was to keep an array of all cell objects getting created in the table and then make them stop listening when the view is dismissed like this:

-(void) viewWillDisappear:(BOOL)animated
{
    for (UploadCell *aCell in lol)
    {
        [aCell stopListening];
    }

    [self.navigationController popViewControllerAnimated:YES];
}

But this seems like a bit of a hack. How would I go about making sure that the custom cell objects are deleted when the view is dismissed? Because when the view is intialized again, new cells are simply made anyways, so I have no use for the old ones.

The custom view cells have a strong property pointer to the tableview they get associated with, but I thought the ARC would make sure that TableView pointer would not get invalidated then? Obviously it is somehow. Maybe because of the containing view being deleted when popped?

  • 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-30T01:10:38+00:00Added an answer on May 30, 2026 at 1:10 am

    Sounds like the cells have a retain property pointing back to your UITableViewDataSource class.

    They should instead have an assign property, then they will be released properly when the table view is released (which it currently cannot be if your cells are retaining it).

    Also, the cells should shut down notifications when they are dropped out of the tableview, by overriding the cells didMoveToSuperview method:

    - (void)didMoveToSuperview
    {
        [super didMoveToSuperview];
        if ( [self superview] == nil )
        {
            [self unsubscribeFromYourNotifications];
        }
    }
    

    That is so if they scroll off screen they will not be wasting resources updating things.

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

Sidebar

Related Questions

I just have a quick question about how to get the length of a
I recall I have read about a parser which you just have to feed
Caching a complex application can get hairy very quickly. My question is do developers
This question is more for my personal curiosity than anything important. I'm trying to
I just have started to learn Haskell and combine reading books and tutorials with
I just have an XP machine, and i want to play around using CC.NET.
Currently I just have a file like this that I manually parse into a
So I have site list on certain pages that basically just have links to
I've recently decided that I just have to finally learn C/C++, and there is
I am just going to submit my iphone application . But I just have

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.