• 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: Bill Bumgarner <email@hidden>
  • Date: Mon, 29 Oct 2007 13:30:17 -0700

On Oct 29, 2007, at 12:18 PM, glenn andreas 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?

It depends on if you are writing pure-GC or dual mode code.

In either case, you could:

- (id) getSomethingFromCarbon
{
	CFFooReference cffoo = CFCopyFooWithBar(5);
	return [NSMakeCollectable((id)cffoo) autorelease];
}

This will work for both GC and non-GC modes. However, if you are writing an application, I would suggest that you turn on "GC Only" mode. This eliminates the relatively small amount of overhead incurred by the need for code to run in both GC or non-GC modes.

In that case, you would eliminate the -autorelease:

- (id) getSomethingFromCarbon
{
	CFFooReference cffoo = CFCopyFooWithBar(5);
	return NSMakeCollectable((id)cffoo);
}

You can also use CFMakeCollectable() -- same as NSMakeCollectable() but with CF typed parameter and return value.

There is an excellent Garbage Collection Programming Guide included with Xcode 3.0 that explains all of this and a lot more.

b.bum

_______________________________________________

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: Collection was mutated while being enumerated
  • Previous by thread: Re: [Leopard] Debugging GC
  • Next by thread: Re: [Leopard] Debugging GC
  • Index(es):
    • Date
    • Thread