Possible Duplicate:
Local variable assign versus direct assign; properties and memory
Which way is the correct way to allocate memory with a property?
I wanted to know the difference between this two code examples.
1:
NSString *someString = @"Blabla";
{...Some code...}
imageView.title = [[NSString alloc] initWithString:someString];
2:
NSString *someString = @"Blabla";
{...Some code...}
NSString *str = [[NSString alloc] initWithString:someString];
imageView.title = str;
[str release];
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.
Does anyone know Whats the reason for that?
Thank you very much!