Re: [Leopard] Debugging GC
Re: [Leopard] Debugging GC
- Subject: Re: [Leopard] Debugging GC
- From: "Clark Cox" <email@hidden>
- Date: Mon, 29 Oct 2007 13:23:13 -0700
On 10/29/07, glenn andreas <email@hidden> wrote:
> It use to be that if you called a CFCopy style routine, you could
> return the result via autorelease, something like:
>
> - (id) getSomethingFromCarbon
> {
> CFFooReference cffoo = CFCopyFooWithBar(5);
> return [(id)cffoo autorelease];
> }
>
> (assuming CFFooReference was one of the bridged objects).
>
>
> So what is the correct idiom now?
-(id)getSomethingFromCarbon
{
CFFooReference cffoo = CFCopyFooWithBar(5);
return [NSMakeCollectable(cffoo) autorelease];
}
This does the right thing under bot GC and non-GC. Under GC, the
NSMakeCollectable decrements the retain count and makes the object
collectable, while the autorelease is a no-op. Without GC, the
NSMakeCollectable is a no-op, and the autorelease functions as it
always has.
--
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