Re: Toll Free Bridging and Garbage Collection
Re: Toll Free Bridging and Garbage Collection
- Subject: Re: Toll Free Bridging and Garbage Collection
- From: j o a r <email@hidden>
- Date: Mon, 26 Nov 2007 08:20:11 -0800
On Nov 26, 2007, at 7:51 AM, Paul Sargent wrote:
The calling code is going to treat the returned string as an
NSString and not know it needs releasing, but if I release it before
returning it, it won't be valid.
Is there a way round this or do I need to create a proper NSString,
pass that back (A toll bridge if you like), and release the CFString?
See CFMakeCollectable / NSMakeCollectable:
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/macro/NSMakeCollectable
>
<http://developer.apple.com/documentation/CoreFoundation/Reference/CFTypeRef/Reference/reference.html#//apple_ref/c/func/CFMakeCollectable
>
<http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcAPI.html
>
Note that you only have to use the slightly weird looking
"[NSMakeCollectable(aCFRef) autorelease]" construct if you maintain a
library that has to support both garbage-collected and non-garbage-
collected environments. In most cases you would just return the value
from CF/NSMakeCollectable straight away.
j o a r
_______________________________________________
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