title: Weak references in blocks and retain cycles
body: <p><a href="https://stackoverflow.com/questions/11603284/weak-references-inside-a-block">In this question</a>, I asked about the following code and retain cycles:</p>
  
  <pre><code>__weak Cell *weakSelf = self;
  NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock:^{
          UIImage *image = /* render some image */
          [[NSOperationQueue mainQueue] addOperationWithBlock:^{
              [weakSelf setImageViewImage:image];
          }];
      }];
      [self.renderQueue addOperation:op];
  </code></pre>
  
  <p>All answers state that using a weak reference here was not necessary, since this code does not result in a retain cycle. However, while experimenting with some more code, the following does result in a retain cycle (if I don't use a weak reference, the current view controller is not deallocated)</p>
  
  <pre><code>    //__weak ViewController *weakSelf = self;
      MBItem *close = [[MBItem alloc] initWithBlock:^{
          [self dismissModalWithDefaultAnimation:NO];
      }];
      NSMutableArray *items = [[NSMutableArray alloc] initWithObjects:close, nil];
      [self.childObject setItems:items];
  </code></pre>
  
  <p>Why would the second one result in a retain cycle but not the first one?</p>