Re: Garbage Collection, Core Foundation, and the -finalize problem
Re: Garbage Collection, Core Foundation, and the -finalize problem
- Subject: Re: Garbage Collection, Core Foundation, and the -finalize problem
- From: Michael Tsai <email@hidden>
- Date: Mon, 16 Mar 2009 14:32:49 -0400
On Mar 16, 2009, at 2:08 PM, Bill Cheeseman wrote:
I am looking for a strategy to avoid implementing a -finalize method
in a garbage-collected Objective-C class that declares a CFTypeRef-
style Core Foundation instance variable. I believe this is a fairly
common problem, because any Cocoa wrapper class for a Core
Foundation API would have to do it, but I haven't seen a usable
solution. Apple's GC documentation stops just short of suggesting an
answer.
I believe you're supposed to declare your CFTypeRef ivar as __strong
and call CFMakeCollectable so that the garbage collector will be
responsible for releasing it. You can still use CFRelease in -dealloc
for when you aren't running under garbage collection.
--Michael
_______________________________________________
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