Re: Stack-based C++ class to wrap NSAutoreleasePool
Re: Stack-based C++ class to wrap NSAutoreleasePool
- Subject: Re: Stack-based C++ class to wrap NSAutoreleasePool
- From: BJ Homer <email@hidden>
- Date: Mon, 16 Nov 2009 12:28:21 -0700
Does the stack-based idiom allow returning an autoreleased object? I'd
think you'd end up with code like this:
- (id)arrayWithStuff {
StackAutoreleasePool();
NSArray *array = [NSArray arrayWithObjects:obj1, obj2, etc, nil];
return array;
}
which would essentially translate into:
- (id)arrayWithStuff {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *array = [NSArray arrayWithObjects:obj1, obj2, etc, nil];
[pool release];
return array; // array is dead
}
Is there some reason why this would not happen?
-BJ
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden