title: EXC_BAD_ACCESS error on dismissing modal UIViewController
body: <p>This is my first post here.</p>
  
  <p>I'm a newbie to the iPhone SDK. Please answer my question even if it is simple.
  I've created a navigation based application. The hierarchy as follows:</p>
  
  <p><em>NavigationController - RootViewController
                       - ATableViewController (pushed over RootViewController)</em></p>
  
  <p>On RootViewController first I've pushed ATableViewController. Then, I'm presenting a view controller with TabBarController (which has four tabs each having its own navigation controller).</p>
  
  <p>Now I want to keep two buttons on each navigation controller. On clicking one it should dismiss the modal view controller and on clicking the other it should return to RootViewController.</p>
  
  <p>So, I've kept button on the <code>UINavigationBar</code> to dismiss the modal view controller. However on dismissing it I'm receiving an error:</p>
  
  <p><code>*** -[CALayer superlayer]: message sent to deallocated instance 0xb157840</code></p>
  
  <p>the backtrace is:</p>
  
  <pre><code>#0  0x011bb657 in ___forwarding___ ()
  #1  0x011bb522 in __forwarding_prep_0___ ()
  #2  0x004c54e5 in _UIConvertDisplayPointToWindow ()
  #3  0x004c5695 in +[UIWindow _hitTestToPoint:pathIndex:forEvent:] ()
  #4  0x004a5709 in _UIApplicationHandleEvent ()
  #5  0x01cf8992 in PurpleEventCallback ()
  #6  0x0122b944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
  #7  0x0118bcf7 in __CFRunLoopDoSource1 ()
  #8  0x01188f83 in __CFRunLoopRun ()
  #9  0x01188840 in CFRunLoopRunSpecific ()
  #10 0x01188761 in CFRunLoopRunInMode ()
  #11 0x01cf71c4 in GSEventRunModal ()
  #12 0x01cf7289 in GSEventRun ()
  #13 0x004aac93 in UIApplicationMain ()
  #14 0x00001cd9 in main (argc=1, argv=0xbffff678) at main.m:14
  </code></pre>
  
  <p>Anyone please please help me out. I'm struggling with this problem from two weeks. I've spent many hours googling it.</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Thanks for reading.</p>