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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:46:24+00:00 2026-05-29T10:46:24+00:00

Is it necessary to set all @property s with retain modifier declared as IBOutlet

  • 0

Is it necessary to set all @propertys with retain modifier declared as IBOutlet to nil inside the - (void)dealloc method? Will memory be consumed / wasted if I don’t do so?

Assume that Automatic Reference Counting is turned OFF.

  • 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-29T10:46:25+00:00Added an answer on May 29, 2026 at 10:46 am

    Your question seems to be “How do I handle a retain property in dealloc?” Well let’s look at an example.

    @property (retain, nonatomic) IBOutlet UIView *myView;
    

    When your view is loaded myView is retained by two objects, your view hierarchy (by an internal addSubview: or similar) and your view controller (by means of the property setter method). A simple log is all that is needed to confirm this. placing this code in viewDidLoad will confirm this with an output of 2.

    NSLog(@"myLabel is retained: %i", myView.retainCount);
    

    There are two methods where you should address this pointer, and both are automatically filled in for you by Xcode.

    First in viewDidUnload (Which is generally only called in low memory situations) you want to release the view, and since that will result in a dangling pointer you also want to set the pointer to nil. Xcode achieves this by simply using the setter method.

    [self setMyView:nil];
    

    The second place, and the place you asked about initially is dealloc. In dealloc you similarly need to release your property although in this case (Main thread only execution, based on the IBOutlet in the question) the dangling pointer should not be a problem. This seems reinforced by Xcode’s automatic implementation of dealloc.

    [myView release];
    

    Of course setting the pointer to nil in addition to releasing would not be detrimental at all. And may even be preferable if this were not a main thread only UIKit element. But if you were worried about multi-threading you would likely just use atomic instead.

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

Sidebar

Related Questions

Is it necessary to set large objects to null when implementing a Dispose() method?
By generate, I mean auto-generation of the code necessary for a particular selected (set
The question gives all necessary data: what is an efficient algorithm to generate a
It is necessary to switch off the ClearType property of the default font for
One feature of Threads is that you can set the .IsBackground property to true,
If necessary, a factory can access elements of the infrastructure to build an object?.
How necessary is it to search for a path to an image using the
not necessary an UML diagram, just a simple way to graphically document the relations
Is it necessary for me to call allocator.construct() for an array of primitive types
Is that return necessary? Let's say it's in the middle of an action. render(contentType:'text/json',

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.