title: Objective-C NSString's memory management
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3066848/local-variable-assign-versus-direct-assign-properties-and-memory">Local variable assign versus direct assign; properties and memory</a><br>
    <a href="https://stackoverflow.com/questions/7395253/which-way-is-the-correct-way-to-allocate-memory-with-a-property">Which way is the correct way to allocate memory with a property?</a>  </p>
  </blockquote>
  
  
  
  <p>I wanted to know the difference between this two code examples.</p>
  
  <h1>1:</h1>
  
  <pre><code>NSString *someString = @"Blabla";
  
  
  {...Some code...}
  
  
  imageView.title = [[NSString alloc] initWithString:someString];
  </code></pre>
  
  <h1>2:</h1>
  
  <pre><code>NSString *someString = @"Blabla";
  
  
  {...Some code...}
  
  
  NSString *str = [[NSString alloc] initWithString:someString];
  imageView.title = str;
  [str release];
  </code></pre>
  
  <p>For some reason Xcode Analyzer warns me that option #1 might cause to memory leak- so when I change my code to option #2 the analyzer doesn't warn me.</p>
  
  <p>Does anyone know Whats the reason for that?</p>
  
  <p>Thank you very much!</p>