title: Custom dealloc and ARC (Objective-C)
body: <p>In my little iPad app I have a "switch language" function that uses an observer. Every view controller registers itself with my observer during its <code>viewDidLoad:</code>.</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      [observer registerObject:self];
  }
  </code></pre>
  
  <p>When the user hits the "change language" button, the new language is stored in my model and the observer is notified and calls an <code>updateUi:</code> selector on its registered objects.</p>
  
  <p>This works very well, except for when I have view controllers in a TabBarController.  This is because when the tab bar loads, it fetches the tab icons from its child controllers without initializing the views, so <code>viewDidLoad:</code> isn't called, so those view controllers don't receive language change notifications. Because of this, I moved my <code>registerObject:</code> calls into the <code>init</code> method.</p>
  
  <p>Back when I used <code>viewDidLoad:</code> to register with my observer, I used <code>viewDidUnload:</code> to unregister. Since I'm now registering in <code>init</code>, it makes a lot of sense to unregister in <code>dealloc</code>.</p>
  
  <p>But here is my problem. When I write:</p>
  
  <pre><code>- (void) dealloc
  {
      [observer unregisterObject:self];
      [super dealloc];
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>ARC forbids explicit message send of 'dealloc'</p>
  </blockquote>
  
  <p>Since I need to call <code>[super dealloc]</code> to ensure superclasses clean up properly, but ARC forbids that, I'm now stuck. Is there another way to get informed when my object is dying?</p>