On Sep 18, 2009, at 12:04 PM, Stuart Malin wrote:

I am under the impression that the reference returned by NSString's UTF8String method is valid for the life of the NSString instance which provided the reference (and further, that the memory of the referenced C string is freed when the NSString is released). Is this correct?

The only way to be sure is to run Instruments with the object allocations tool and look for allocations equal to the size of the string. But I'm pretty sure that draining the autorelease pool frees the C strings, or at least, they do get cleaned up at some point.

In any case, if you want them to stick around, then you need to memcpy () them into a data buffer that is controlled by your application.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to