Re: dataWithBytesNoCopy:length:freeWhenDone
Re: dataWithBytesNoCopy:length:freeWhenDone
- Subject: Re: dataWithBytesNoCopy:length:freeWhenDone
- From: email@hidden
- Date: Sun, 09 Oct 2011 14:46:47 +0200
On 2011-10-09, at 05:50, Ken Thomases wrote:
>> I'd guess that, with the 'NO' parameter, NSMutableData copies the data anyway.
>
> This is actually documented. In the Binary Data Programming Guide, in the article Working With Binary Data[1], it says:
>
>> However, if you create an NSData object with one of the methods whose name includes NoCopy (such as dataWithBytesNoCopy:length:), the bytes are not copied. Instead, the data object takes ownership of the bytes passed in as an argument and frees them when the object is released. (NSMutableData responds to these methods, too, but the bytes are copied anyway and the buffer is freed immediately.)
I see. I even read this document but it seems I was reading too fast and I missed the part in parentheses. Thank you for pointing out. Although I believe this should rather be placed in the class documentation..
Regards,
--
SD!_______________________________________________
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