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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:38:17+00:00 2026-06-13T11:38:17+00:00

-(void)viewDidUnload { [[NSNotificationCenter defaultCenter] removeObserver:self name:LASTUPDATEDLOCATION object:nil]; [self setHeaderViewofWholeTable:nil]; [self setFooterViewofWholeTable:nil]; [self setHeaderActivityIndicator:nil]; [self

  • 0
-(void)viewDidUnload
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:LASTUPDATEDLOCATION object:nil];
    [self setHeaderViewofWholeTable:nil];
    [self setFooterViewofWholeTable:nil];
    [self setHeaderActivityIndicator:nil];
    [self setFooterActivityIndicator:nil];
    [self setLastUpdated:nil];
    [self setLblPullDowntoRefresh:nil];
    [self setRefreshArrow:nil];
    [self setContainerForFormerHeader:nil];
    [self setFooterContainer:nil];
    [super viewDidUnload];
}

I thought viewDidLoad is called the view itself goes nil. When we set the view to nil, wouldn’t all those things automatically become nil?

What am I misunderstanding?

  • 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-13T11:38:18+00:00Added an answer on June 13, 2026 at 11:38 am

    Some of the other answers cover some of this but there is more to this. A view controller will have its viewDidLoad method called. Typically this results in IBOutlets being retained and possibly lots of other views and objects being allocated and retained. If all goes well, eventually the view controller is deallocated and all of those retained objects need to be released.

    That’s the simple, happy path. Under low memory conditions, in iOS 5 and earlier, it is possible that a view controller’s view will be unloaded. The viewDidUnload method was a chance for you to clean up all of the other objects that were retained as part of the viewDidLoad process. And here’s the main reason – at some point, viewDidLoad may be called again to redisplay the view controller’s view.

    Most people write their viewDidLoad method like it will only ever be called once. And this is OK if the viewDidUnload method properly clears up objects. If it doesn’t, the next call to viewDidLoad will result in a bunch of memory leaks.

    ARC pretty much eliminated the issue with the memory leaks if you didn’t clean things up properly in viewDidUnload. But viewDidUnload was still helpful for cleaning up memory when needed.

    As was mentioned, as of iOS 6, a view controller’s view in never unloaded in low memory conditions and the viewDidUnload (and viewWillUnload) methods have been deprecated.

    If your app still supports iOS 5 along with iOS 6, you still need to make proper use of viewDidUnload. But if you want to free up memory when needed, use didReceiveMemoryWarning.

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

Sidebar

Related Questions

I have used Andrew's modified Reachability class. -(void)viewDidLoad [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:nil]; [[NSNotificationCenter defaultCenter]addObserver:self
- (void)viewDidUnload { self.GPSArray = nil; self.accelerometerArray = nil; self.headingArray = nil; self.managedObjectContext =
I'm trying to observe changes to an NSMutableString isDetailView : -(void)viewDidLoad { [self addObserver:self
When I use -addObserverForName: object: queue: usingBlock: for NSNotificationCenter in the -viewDidLoad: method of
What is the -(void)viewDidUnload is good for? Could I not just relase everything in
I used to addObserver in viewDidLoad: and removeObserver in dealloc: . Code: - (void)viewDidLoad
I have a class with this method call within dealloc: - (void)dealloc { [[NSNotificationCenter
- (void)viewDidLoad{ [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@VidName ofType:@mov]; NSURL *url =
- (void)viewDidLoad { [super viewDidLoad]; NSURL *url = [NSURL fileURLWithPath: [NSString stringWithFormat:@%@/Intro2.mp3, [[NSBundle mainBundle]
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view

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.