This is on the iPhone.
So if I have a function like
- (SomeObject*)buildObject;
Do I need to pass a variable that I have already selected outside, for example
- (void)assignObject(SomeObject** out);
Or can I do
- (SomeObject*)buildObject
{
return [[[SomeObject alloc] init] autorelease];
}
and use it like
SomeObject* obj = [[otherObject buildObject] retain];
I would like to do the latter, but as far as I read it is undefined because autorelease only guarantees the object to the end of the function?
source
share