If I allocate an object in a method, 'getASprocket' and call it this way, will there be a leak here?
Sprocket *sprock = [Sprocket getASprocket];
// store this returned value as an ivar
ivarSprock = [sprock retain];
// release the originally acquired object
[sprock release];
The Sprocket object is allocated and returned this way:
– (Sprocket *)getASprocket {
Sprocket *sprocket;
sprocket = [[Sprocket alloc] init];
return [sprocket retain];
}
Also, would changing from '[sprocket retain];'
inside the 'aSprocket' method to 'return [sprocket autorelease];'
make worse performance hit?