This is on the iPhone.
So what if I have a function like
- (SomeObject*)buildObject;
Do I need to pass in a variable that I have already alloc'd outside like
- (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 last one, but as far as I've read this is undefined because autorelease only guarantees the object until the end of the function?