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: Clark Cox <email@hidden>
- Date: Sat, 14 Nov 2009 15:17:25 -0800
On Sat, Nov 14, 2009 at 12:10 PM, Kyle Sluder <email@hidden> wrote:
> On Sat, Nov 14, 2009 at 9:53 AM, Clark Cox <email@hidden> wrote:
>> The one thing to be careful of is exceptions. In 32-bit Mac code,
>> Obj-C and C++ exceptions are completely unrelated. If an Objective-C
>> exception is thrown, C++ destructors will *not* be called as the stack
>> is unwound. Just something to be aware of.
>
> And even in 64-bit code, most of Cocoa is *not* objection-safe. So if
> you throw an exception through Cocoa stack frames, they won't catch it
> and clean up after themselves.
Indeed, but I'm talking about the opposite situation. Something in
Cocoa throws an exception up through *your* code not you throwing an
exception through *Cocoa's* code. Code using C++ RAII idioms will
function properly in the presence of Obj-C exceptions on the
64-bit/iPhone runtime. The same cannot be said of code on the 32-bit
Mac runtime.
--
Clark S. Cox III
email@hidden
_______________________________________________
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