As per the clang ARC spec, a method argument of the form NSError **
(or rather, a pointer to any obj-c object) is implicitly assumed to be NSError * __autoreleasing *
. This means that the error will be autoreleased in the method.
As for the call site, if you call it with an __autoreleasing
variable, as you have, then everything is just fine. In fact, I recommend this pattern. However, it will still work if you call it with a __strong
variable instead. In that case, the compiler will generate an unnamed __autoreleasing
temporary, pass the address of that to the method, and then upon return, it will assign the temporary into the __strong
. So if you have
NSError *foo;
[bar callMethodWithError:&foo];
the compiler will treat this the same as
NSError *foo;
NSError * __autoreleasing tmp = foo;
[bar callMethodWithError:&tmp];
foo = tmp;
It's actually slightly more complicated than that if the out-param is marked out
, but this is generally how it works.