• 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: Toll Free Bridging and Garbage Collection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Toll Free Bridging and Garbage Collection (From: Paul Sargent <email@hidden>)

  • Prev by Date: Creating subviews programmatically ?
  • Next by Date: Re: Creating subviews programmatically ?
  • Previous by thread: Toll Free Bridging and Garbage Collection
  • Next by thread: Re: Toll Free Bridging and Garbage Collection
  • Index(es):
    • Date
    • Thread