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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:35:03+00:00 2026-06-11T03:35:03+00:00

Given that we are writing code with ARC, should I nil properties in viewDidUnload

  • 0

Given that we are writing code with ARC, should I nil properties in viewDidUnload, that are instantiated from:

  1. XIB (here the nilling is sometimes generated from IDE)

  2. from initialiser and have not IBOutlet

  3. that are weak

?

  • 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-11T03:35:05+00:00Added an answer on June 11, 2026 at 3:35 am

    The purpose of viewDidUnload is to give your app a chance to remove references to user interface objects that may no longer exist because the view was removed upon receiving a memory warning. Thus:

    1. You should be setting any user interface controls to nil (because the view is being unloaded). Unnecessary for weak properties (and they generally should be weak per Apple guidance on this topic), but if Xcode inserts it in for you, it’s not a problem. For guidance on what to do in viewDidUnload see the “Memory Warnings” section of the Resource Programming Guide: The Nib Files.

    2. And for non-user interface objects that you set up in viewDidLoad, I’d be wary about just blindly setting those to nil in viewDidUnload, especially if you’re not using ARC (e.g. if you accidentally nil the instance variable, you might cause a leak). And you probably want to balance the amount of memory that will be recovered versus the “cost” of re-retrieving that data (e.g. if it’s from some remote server). Regardless, I’d suggest that you handle the freeing of memory for non-UI objects in didReceiveMemoryWarning.

    In my mind, I view viewDidUnload as a chance to make sure I’m not maintaining references to user interface objects that might no longer exist, and I use didReceiveMemoryWarning to empty caches or other non-UI related items that I can safely purge to recover some memory. And if you’re concerned about iOS 6, note that the handling of viewDidUnload may be changing, and while the NDA precludes us from discussing it publicly, I might advise that you may want to refer to the iOS 6 Beta 4 Release Notes and look for references to viewDidUnload.

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

Sidebar

Related Questions

I'm writing some code that will take a screenshot of another application, given its'
I'm writing code to recursively replace predefined variables from inside a given string. The
I am writing a script that checks if given domain is parked or not.
I'm current writing a short bit of code that will compare an etag for
I'm writing a webcrawler in Python that will store the HTML code of a
I'm writing code that will run on Linux, OS X, and Windows. It downloads
I am writing the code for a server that would help two different applications
I am writing code that checks for the permission to write to and delete
A problem I keep running into when writing code that draws images of scientific
I am writing code in Java that uses an unordered, rooted tree where each

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.