• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Leopard] Debugging GC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >[Leopard] Debugging GC (From: Pierre Bernard <email@hidden>)
 >Re: [Leopard] Debugging GC (From: Bill Bumgarner <email@hidden>)
 >Re: [Leopard] Debugging GC (From: John Stiles <email@hidden>)
 >Re: [Leopard] Debugging GC (From: mmalc crawford <email@hidden>)
 >Re: [Leopard] Debugging GC (From: John Stiles <email@hidden>)
 >Re: [Leopard] Debugging GC (From: mmalc crawford <email@hidden>)
 >Re: [Leopard] Debugging GC (From: glenn andreas <email@hidden>)

  • Prev by Date: Re: Opening projects in upgraded OS
  • Next by Date: Re: AEDesc and NSAppleEventDescriptor
  • Previous by thread: Re: [Leopard] Debugging GC
  • Next by thread: Re: [Leopard] Debugging GC
  • Index(es):
    • Date
    • Thread