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

  • Home
  • SEARCH
  • 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 8428719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:07:59+00:00 2026-06-10T05:07:59+00:00

I am new to iphone development . I am using ARC for my project.

  • 0

I am new to iphone development . I am using ARC for my project. As far as I understood using ARC we don’t have to release any object manually. But , I have observed in some places , people explicitly set their object to nil in the ViewDidUnload even after using ARC.

For example, in .h file I have something like this:

@property (unsafe_unretained, nonatomic) IBOutlet MKMapView *mapViewOutlet;
@property (unsafe_unretained, nonatomic) IBOutlet UIToolbar *toolBar;
@property (strong,nonatomic) NSMutableArray *dataArray;

And .m as follows:

- (void)viewDidUnload
{
     [self setMapViewOutlet:nil];
     [self setToolBar:nil];
     [super viewDidUnload];
     self.dataArray=nil;
}

My question is, is it really necessary to explicitly specify nil in the ViewDidUnload even under ARC?

  • 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-10T05:08:00+00:00Added an answer on June 10, 2026 at 5:08 am

    The whole point of the viewDidUnload method is to release data that you don’t really need, in order to free memory. Read the documentation:

    When a low-memory condition occurs and the current view controller’s
    views are not needed, the system may opt to remove those views from
    memory. This method is called after the view controller’s view has
    been released and is your chance to perform any final cleanup. If your
    view controller stores separate references to the view or its
    subviews, you should use this method to release those references. You
    can also use this method to remove references to any objects that you
    created to support the view but that are no longer needed now that the
    view is gone. You should not use this method to release user data or
    any other information that cannot be easily recreated.

    So you’re setting the properties to nil in order to release the objects now and help the system to free up some memory. But of course this depends on the property type – strong properties are “yours” and only you can decide whether to release them now (by setting to nil) or not. Weak properties could already be nil, for example if they pointed to some views that got released with the main view. And unsafe_unretained properties are a special beast. The object they point to might already been released, but that does not mean they were set to nil automatically. So you should either use one of the “safer” property types (strong/weak), or set the unsafe properties to nil here, to make sure you won’t use the released object later. There are no hard rules in this case, you have to think about the situation and what it means for the various properties.

    By the way, viewDidUnload is getting deprecated in iOS 6, where no views are being released under low-memory conditions anymore. You still receive the didReceiveMemoryWarning callback, so that you can release some resources there if you want to. Again, I suggest that you read the documentation and run a few tests to see what happens and decide what you should do.

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

Sidebar

Related Questions

I am new to iPhone development.I have created an application using UITableViewCellAccessoryDisclosureIndicator . I
I am new to iPhone development. I have created the database using the terminal
I´m new in iPhone development and I have this memory leak. I´m using an
I am new to iphone development, i have created sms application using Text Links(sms:)
I am new to iPhone development and trying to load PNGs using libpng but
I am new to iPhone development. I am using the below code to add
I am new on iPhone development. I am making an app, using sqlite3 for
I am Abbas,I am new to iPhone Development, Till tomorrow i am using xcode
I am new to Objective C and iPhone development. I am using CoreData on
Im new to iPhone development and I have really taken this to me. I

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.