title: iPhone - EXC_BAD_ACCESS when setting nil to an IBOutlet - Memory Management
body: <p>I'm facing an annoying issue and I can't find out why.</p>
  
  <p>I have a UIViewController I present in modal like that :</p>
  
  <pre><code>interviewsViewController *interviewsVC = [[interviewsViewController alloc] initWithNibName:nil bundle:nil];
  [interviewsVC setManagedObjectContext:_managedObjectContext];
  
  UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:interviewsVC];
  [interviewsVC release];
  [self presentModalViewController:navigationController animated:YES];
  [navigationController release];
  </code></pre>
  
  <p>Then when I dismiss the view controller like this :</p>
  
  <pre><code>- (void)dismissViewController
  {
       [self dismissModalViewControllerAnimated:YES];
  }
  </code></pre>
  
  <p>The dealloc gets called :</p>
  
  <pre><code>- (void)dealloc
  {
      [_managedObjectContext release];
      [_interviewsArray release];
      [scrollView release];
      [pageControl release];
  }
  </code></pre>
  
  <p>Once the view controller is dismissed, I send an memory warning via the iPhone Simulator Menu and the viewdidunload method gets called :</p>
  
  <pre><code>- (void)viewDidUnload
  {
      [super viewDidUnload];
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
      self.scrollView = nil;
      self.pageControl = nil;
  }
  </code></pre>
  
  <p>But there's always an error EXC_BAD_ACCES on the self.scrollView = nil ... More specifically at this line :</p>
  
  <pre><code>@synthesize scrollView;
  </code></pre>
  
  <p>And I can't find out why ?</p>
  
  <p>If I add a breakpoint on the line above this one, the scrollView is not a zombie or equal to 0x0 ...</p>
  
  <p>Do you have an idea ?</p>
  
  <p>PS : Here's the header : </p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface interviewsViewController : UIViewController &lt;UIScrollViewDelegate&gt;
  {
      NSManagedObjectContext *_managedObjectContext;
  
      NSMutableArray *_interviewsArray;
  
      NSUInteger _fetchOffset;
  
      CGFloat _lastXValue;
  }
  
  @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
  @property (nonatomic, retain) NSMutableArray *interviewsArray;
  
  //IBOutlet
  @property (nonatomic, retain) IBOutlet UIScrollView *scrollView;
  @property (nonatomic, retain) IBOutlet UIPageControl *pageControl;
  </code></pre>
  
  <p>And I set the delegate of the scrollview in the XIB (not in the code).</p>