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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:00:48+00:00 2026-05-26T11:00:48+00:00

I am trying to learn Automatic Reference Counting in iOS 5. Now the first

  • 0

I am trying to learn Automatic Reference Counting in iOS 5. Now the first part of this question should be easy:

  1. Is it correct that I do NOT need to write explicit
    release-property statements in my dealloc when using ARC? In other
    words, is it true that the following does NOT need a explicit
    dealloc?

    @interface MyClass : NSObject
    @property (strong, nonatomic) NSObject* myProperty;
    @end
    
    @implementation MyClass
    @synthesize myProperty;
    @end
    
  2. My next and more important question comes from a line in the Transitioning to ARC Release Notes document:

    You do not have to (indeed cannot) release instance variables, but you may need to invoke [self setDelegate:nil] on system classes and other code that isn’t compiled using ARC.

    This begs the question: how do I know which system classes are not compiled with ARC? When should I be creating my own dealloc and explicitly setting strongly retaining properties to nil? Should I assume all NS and UI framework classes used in properties require explicit deallocs?

There is a wealth of information on SO and elsewhere on the practices of releasing a property’s backing ivar when using manual reference tracking, but relatively little about this when using 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-05-26T11:00:48+00:00Added an answer on May 26, 2026 at 11:00 am

    Short answer: no, you do not have to nil out properties in dealloc under ARC.

    Long answer: You should never nil out properties in dealloc, even in manual memory management.

    In MRR, you should release your ivars. Nilling out properties means calling setters, which may invoke code that it shouldn’t touch in dealloc (e.g. if your class, or a subclass, overrides the setter). Similarly it may trigger KVO notifications. Releasing the ivar instead avoids these undesired behaviors.

    In ARC, the system automatically releases any ivars for you, so if that’s all you’re doing you don’t even have to implement dealloc. However, if you have any non-object ivars that need special handling (e.g. allocated buffers that you need to free()) you still have to deal with those in dealloc.

    Furthermore, if you’ve set yourself as the delegate of any objects, you should un-set that relationship in dealloc (this is the bit about calling [obj setDelegate:nil]). The note about doing this on classes that aren’t compiled with ARC is a nod towards weak properties. If the class explicitly marks its delegate property as weak then you don’t have to do this, because the nature of weak properties means it’ll get nilled out for you. However if the property is marked assign then you should nil it out in your dealloc, otherwise the class is left with a dangling pointer and will likely crash if it tries to message its delegate. Note that this only applies to non-retained relationships, such as delegates.

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

Sidebar

Related Questions

I'm trying to learn C++ so forgive me if this question demonstrates a lack
Trying to learn Django, I closed the shell and am getting this problem now
This is a noob question. I'm trying to learn how to use SWIG to
Trying to learn a bit about PDO and is going through this tutorial .
I am trying to learn inline assembly programming in Delphi, and to this end
I'm trying to learn C from a Ruby/PHP/Java background, and I've found that you
Trying to learn PL/SQL with multimedia data. Can anyone please point out that from
Trying to learn Regex in Python to find words that have consecutive vowel-consonant or
I'm trying learn Python (3 to be more specific) and I'm getting this error:
Trying to learn pointer math better I wrote this code. The intention was to

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.