title: Changes to reference counting in iOS 7?
body: <p>I'm currently working on fixing some iOS 7 display issues on a legacy app which was not built with ARC, and have run into some inconsistent behaviour with the <code>dealloc</code> method between iOS versions 6 &amp; 7. I can't find any other mention of these changes in any documentation or community discussions, so I wonder if anyone here could shed some light on what's happening here?</p>
  
  <p>My previous code, (which works in iOS6, looks like this):</p>
  
  <pre><code>@interface MyViewController()
  @property (retain) AdHandler *adHandler;
  @end
  
  @implementation MyViewController
  
  @synthesize adHandler = _adHandler;
  
  - (id) initWithAdHandler:(AdHandler*)anAdHandler
  {
      self = [super init];
      _adHandler = [anAdHandler retain];
      return self;
  }
  
  - (void)dealloc
  {    
      [super dealloc];
  
      [_adHandler release];
      _adHandler = nil;
  }
  
  ...
  
  @end
  </code></pre>
  
  <p>When stepping through the code in iOS 6, I've found that after the <code>dealloc</code> statement, <code>[_adHandler retainCount]</code> is still positive, and the object is still available.</p>
  
  <p>In iOS 7 however, after the <code>dealloc</code> statement, <code>retainCount</code> has somehow hit zero, and the <code>_adHandler</code> object has been <code>dealloc</code>'d, and therefore my call to <code>release</code> causes an <code>EXC_BAD_ACCESS</code>.</p>
  
  <p>I can fix this simply by moving my <code>[adHandler release]</code> call to before the <code>dealloc</code> call, but my question is why is this happening? Why is <code>dealloc</code> releasing objects that it has no responsibility for? Is there any documentation anywhere on why dealloc behaviour has changed in this way?</p>