• 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: GC and propertyListFromData:mutabilityOption:format:errorDescription:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GC and propertyListFromData:mutabilityOption:format:errorDescription:


  • Subject: Re: GC and propertyListFromData:mutabilityOption:format:errorDescription:
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 10 Nov 2008 13:22:19 -0800

On Nov 10, 2008, at 11:04, Michael Link wrote:

The documentation for propertyListFromData:mutabilityOption:format:errorDescription: says that errorDescription needs to be released by the caller. In a garbage collected environment is this still the case? Should NSMakeCollectable() be called on errorDescription?

No, because it's a Cocoa data type (NSString*), you don't have to handle it specially. The only time you have to worry about it is for those very few Cocoa methods that return an object of CF data type (and for objects returned by non-Cocoa functions, of course).


This may seem strange because most common Cocoa and CF objects are toll-free bridged -- are, in fact, identical types. The difference is that the memory management is an attribute of the object, not the type. Objects returned as Cocoa types have slightly different memory management semantics.

Is it safe to call NSMakeCollectable() multiple times on the same object (when in doubt)?

It's absolutely not safe. NSMakeCollectable does a CFRelease on the object, which really decrements its retain count, even when garbage collection is in use. (Under garbage collection, CFRelease is not a no- op like 'release' is.)
_______________________________________________


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: 
 >GC and propertyListFromData:mutabilityOption:format:errorDescription: (From: Michael Link <email@hidden>)

  • Prev by Date: Re: MVC and Cocoa question
  • Next by Date: Stop NSFileManager copyFile in progress? Can you kill a thread?
  • Previous by thread: GC and propertyListFromData:mutabilityOption:format:errorDescription:
  • Next by thread: How to write a remote control app for Mac
  • Index(es):
    • Date
    • Thread