title: In which situations do we need to write the __autoreleasing ownership qualifier under ARC?
body: <p>I'm trying to complete the puzzle.</p>
  
  <p><code>__strong</code> is the default for all Objective-C retainable object pointers like NSObject, NSString, etc.. It's a strong reference. ARC balances it with a <code>-release</code> at the end of the scope.</p>
  
  <p><code>__unsafe_unretained</code> equals the old way. It's used for a weak pointer without retaining the retainable object.</p>
  
  <p><code>__weak</code> is like <code>__unsafe_unretained</code> except that it's an auto-zeroing weak reference meaning that the pointer will be set to nil as soon as the referenced object is deallocated. This eliminates the danger of dangling pointers and EXC_BAD_ACCESS errors.</p>
  
  <p>But what exactly is <code>__autoreleasing</code> good for? I'm having a hard time finding practical examples on when I need to use this qualifier. I believe it's only for functions and methods which expect a pointer-pointer such as:</p>
  
  <pre><code>- (BOOL)save:(NSError**);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>NSError *error = nil;
  [database save:&amp;error];
  </code></pre>
  
  <p>which under ARC has to be declared this way:</p>
  
  <pre><code>- (BOOL)save:(NSError* __autoreleasing *);
  </code></pre>
  
  <p>But this is too vague and I'd like to fully understand <em>why</em>. The code snippets I find place the __autoreleasing inbetween the two stars, which looks weird to me. The type is <code>NSError**</code> (a pointer-pointer to NSError), so why place <code>__autoreleasing</code> inbetween the stars and not simply in front of <code>NSError**</code>? </p>
  
  <p>Also, there might be other situations in which I must rely on <code>__autoreleasing</code>.</p>