Re: [NSMutableData resetDataRangeTo:(NSRange)range];
Re: [NSMutableData resetDataRangeTo:(NSRange)range];
- Subject: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
- From: Jens Alfke <email@hidden>
- Date: Mon, 14 Jul 2014 12:53:59 -0700
On Jul 14, 2014, at 12:15 PM, Carl Hoefs <email@hidden> wrote:
> Okay, 1 last question on this. Is there a way to promote-in-place an NSData object into an NSMutableData object? -becomeMutable or some such? I'm trying to avoid copying megabytes of data/sec if it's avoidable.
Nope. Part of the contract of an NSData object is that it’s immutable. If you could change it to mutable, other code that had a reference to that object could find its data changing out from underneath it, causing trouble.
If you’re the one creating the NSData object in the first place, can you create it as an NSMutableData? Then you won’t have to make any copies.
—Jens
_______________________________________________
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