title: What is the difference between a __weak and a __block reference?
body: <p>I'm reading Xcode's documentation, and here is something that puzzles me:</p>
  
  <pre><code>__block typeof(self) tmpSelf = self;
  [self methodThatTakesABlock:^ {
      [tmpSelf doSomething];
  }];
  </code></pre>
  
  <p>The following is copied from the documentation:</p>
  
  <blockquote>
    <p>A block forms a strong reference to variables it captures. If you use
    <code>self</code> within a block, the block forms a strong reference to <code>self</code>, so if
    <code>self</code> also has a strong reference to the block (which it typically
    does), a strong reference cycle results. To avoid the cycle, you need
    to create a weak (or <code>__block</code>) reference to self outside the block, as
    in the example above.</p>
  </blockquote>
  
  <p>I don't understand what does 'a weak (or <code>__block</code>)' mean?</p>
  
  <p>Is</p>
  
  <pre><code>__block typeof(self) tmpSelf = self;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>__weak typeof(self) tmpSelf = self;
  </code></pre>
  
  <p>exactly the same here？</p>
  
  <p>I found another piece in the document:</p>
  
  <blockquote>
    <p>Note: In a garbage-collected environment, if you apply both <code>__weak</code> and
    <code>__block</code> modifiers to a variable, then the block will not ensure that it is kept alive.</p>
  </blockquote>
  
  <p>So, I'm totally puzzled.</p>