Xcode 5 static analyzer fixes #1627
That is correct - and a memory leak that I missed. Just using
But, because ownership was never transferred to ARC, the
Looks good to me.
It's not really ARC reading the name (maybe it does when suggesting quick fixes or static analysis, I'm not sure), but more about conventions set forth here:
Check out the section, "The Create Rule"
So any time you use
When you just use
So if you wanted to manage that memory manually, since we're using ARC and can't call
But, we don't want to do that! We're creating this string one-off and giving it away as a return value. So by using
This essentially consumes the
This is a good SO answer, that could not be more relevant:
Yep, I understand the Create rule ;-)
It just seems clever to me that ARC will know that the return object from that method is an autoreleased object as opposed to a retained object (or is it).
So when we call somewhere else in our code
NSString *myString = [NSString uniqueString];
ARC knows that it doesn't need to release this object (hopefully) since -[NSString uniqueString] returns an autoreleased object (hopefully!)
On 30 Sep 2013, at 23:17, Craig Otis email@example.com wrote:
Yea, I wouldn't so much think of it as an 'autoreleased' object, just as an object that ARC now knows, when compiling, to insert the appropriate
When we call:
Because that method uses
However, the nice thing about ARC/Clang is that it examines the places where the
Aaaah I see. ARC's THAT clever. It looks at the whole scope/lifetime of a variable to see what to do with it.
what if ARC only has the header file (your average framework) for
so it doesn't know that it's a __bridge_transfer object?
On 30 Sep 2013, at 23:39, Craig Otis firstname.lastname@example.org wrote:
If it only has the header file, I'm assuming the implementation file has already been compiled. (Let's say it's a static library.)
In this case, it's safe to assume that the method in the pre-compiled binary already includes an
ARC actually uses autorelease pools (and
I'll look into this to be sure, though. And it goes without saying that in a situation where you have the
So in the case of QSPlugins that use the +[NSString uniqueString] method (examples include the Web Search plugin, Displays plugin and @skurfer's unreleased CloudApp plugin), ARC (and our own manual memory management brains - since it's a convenience method) is assuming that the object is autoreleased - surely we should follow this convention?
On 1 Oct 2013, at 00:24, Craig Otis email@example.com wrote:
Yes, but this has always been the case.
If you're calling a method that returns an object, and does not start with
Where is this convention not being followed?