title: EXC_BAD_ACCESS KERN_INVALID_ADDRESS on controllers dealloc after block returns
body: <p>I've got a <code>UIViewController</code> with <code>UICollectionView</code>, implementing its <code>delegate</code> and <code>dataSource</code>. In 95% everything is working ok, but sometimes I get a crash (log, code etc below). I think it happens when <code>successBlock</code> of <code>myOperation</code> is executed in same moment as the controller gets deallocated (but I'm not sure).</p>
  
  <p>Considering <a href="https://stackoverflow.com/questions/7684742/how-to-solve-kern-invalid-address-on-exc-bad-access-sigsegv">other question from SOF</a> I assume <code>myCollectionView == nil</code>, however the <code>delegate</code> is still pointing somewhere (shouldn't it be changed, it's just assign property as far as I see). I have no idea how to fix such kind of issue, does anyone have any idea?</p>
  
  <p>Crash log:</p>
  
  <pre><code>MyCollectionViewController.m line 0
  __destroy_helper_block_
  Crashed: com.apple.main-thread
  EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x0000000a
  </code></pre>
  
  <p>Call stack:</p>
  
  <pre><code>libobjc.A.dylib 
  objc_msgSend + 5
  retain
  
  UIKit   
  -[UICollectionViewController collectionView] + 54
  
  MyAppName   
  MyCollectionViewController.m line 30
  -[MyCollectionViewController dealloc]
  
  MyAppName   
  MyCollectionViewController.m line 0
  __destroy_helper_block_
  
  libsystem_blocks.dylib  
  _Block_release + 216
  
  MyAppName   
  MyDownloaderController.m line 0
  __destroy_helper_block_75
  
  libsystem_blocks.dylib  
  _Block_release + 216
  
  MyAppName   
  MyOperation.m line 0
  __destroy_helper_block_19
  
  libsystem_blocks.dylib  
  _Block_release + 216
  
  MyAppName   
  MyOperation.m line 0
  __destroy_helper_block_112
  
  libsystem_blocks.dylib  
  _Block_release + 216
  
  UIKit   
  UIApplicationMain + 1136
  
  MyAppName
  main.m line 15
  main
  </code></pre>
  
  <p>Where lines around 30 in MyCollectionViewController:</p>
  
  <pre><code>- (void)dealloc {
      if ([self isViewLoaded] &amp;&amp; self.collectionView) { // line 30
          self.collectionView.delegate = nil;
          self.collectionView.dataSource = nil;
          self.collectionView = nil;
      }
  }
  </code></pre>
  
  <p>My successBlock:</p>
  
  <pre><code>MySuccessHandler successBlock = ^(UIImage *image) {
      if (weakCell) {
          [weakCell.pageImageView setImage:image];
      }
  };
  </code></pre>