Can anyone tell me how I refer to these, is the first a system managed object and the second a user managed object, whats the terminology I should be using in objective-c / cocoa to refer to each of these?
01
+(Planet *) planet {
gPlanetCount++;
return [[[self alloc] init] autorelease];
}
int main(int argc, const char * argv[]) {
Planet *outerMost;
outerMost = [[Planet planet] retain]; // With
...
... some code
...
[outerMost release];
[pool drain];
return 0;
}
// OR
int main(int argc, const char * argv[]) {
Planet *outerMost;
outerMost = [Planet planet]; // Without
...
... some code
...
[pool drain];
return 0;
}
02
+(Planet *) newPlanet {
gPlanetCount++;
return [[self alloc] init];
}
int main(int argc, const char * argv[]) {
Planet *outerMost;
outerMost = [Planet newPlanet];
...
... some code
...
[outerMost release];
[pool drain];
return 0;
}
EDIT_001
So with the first example I would need to have something like this (text moved to 01 at the top)
EDIT_002
"Code cleaned up, revised final question below ..."
I am going to go with 01 (given that its the more usual way) can I ask again about the retain/release (i.e. if they are needed) this compiles and runs through the static analyser both with and without them?
gary