One, you can't use explicit retain
, release
nor autorelease
when under ARC - the compiler won't permit it.
Two, you don't have to think about this at all in this case as it's a simple one - when a strong variable goes out of scope, it's equivalent to a release
message. So how all this works under ARC is:
- (void)watchStrongVariable
{
MyClass *myobj = [self myClassObject]; // implicit retain-on-assignment
// implicit release-on-end-of-scope
}
- (MyClass *)myClassObject
{
return [[MyClass alloc] init]]; // implicit release-after-return
}
Some advice about coding style. One, don't use getXXXX
for getter names - that's reserved for methods which have output artuments (i. e. which accept pointers to be written to), like UIColor's getRed:green:blue:alpha:
method.
Two, for functions, the opening brace goes on a separate line, and the asterisk indicating pointer types shall be collided with the variable name and not the type. So the best is to write int *i;
and not int* i;
nor int * i;
.