• 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: What happens when I call NSMakeCollectable on a CFArrayRef?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What happens when I call NSMakeCollectable on a CFArrayRef?


  • Subject: Re: What happens when I call NSMakeCollectable on a CFArrayRef?
  • From: "Clark Cox" <email@hidden>
  • Date: Sat, 19 Jan 2008 15:17:41 -0800

On Jan 19, 2008 2:56 PM, Andrew Thompson <email@hidden> wrote:
> I want to call a Core function that returns a CFArrayRef and make the
> result garbage collectable.
> The CFArray contains CFStrings...
>
> Is this pattern OK?
>
> -(NSArray *) doFoo {
>    return NSMakeCollectable(CFCopyFoo(someArgs));
> }
>
> Where CFCopyFoo returns a new CFArray containing copied CFStrings.

This will make the array collectable, but will do nothing to the items
contained therein; the contents are still reference counted. However,
this is most likely what you want anyway (Just as in pre-GC code, when
an item is removed from the array, or the array itself is
collected/deallocated, the item will have its reference count
decremented, and will be deallocated if that was the last remaining
reference).

> Or do I have to iterate over the array and call NSMakeCollectable on
> each item in it?

That would do something completely different, and would not be a good
idea (it would be akin to calling CFRelease on each of the items).

--
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

  • Follow-Ups:
    • Re: What happens when I call NSMakeCollectable on a CFArrayRef?
      • From: Andrew Thompson <email@hidden>
References: 
 >What happens when I call NSMakeCollectable on a CFArrayRef? (From: Andrew Thompson <email@hidden>)

  • Prev by Date: Re: why are there zero examples in the cocoa docs?!
  • Next by Date: Re: Linking against HIServices?
  • Previous by thread: Re: What happens when I call NSMakeCollectable on a CFArrayRef?
  • Next by thread: Re: What happens when I call NSMakeCollectable on a CFArrayRef?
  • Index(es):
    • Date
    • Thread