[NSMutableData resetDataRangeTo:(NSRange)range];
[NSMutableData resetDataRangeTo:(NSRange)range];
- Subject: [NSMutableData resetDataRangeTo:(NSRange)range];
- From: Carl Hoefs <email@hidden>
- Date: Sat, 12 Jul 2014 12:36:43 -0700
Basically what I would like is an NSMutableData method like this:
- (void)resetDataRangeTo:(NSRange)range
Parameters
range
The range within the contents of the receiver to be considered the new contents.
But, since that doesn't exist yet, is it safe to "shift" the contents in place of an NSMutableData? I'm trying to avoid having to copy the contents, which is > 1MB.
In this example, I want to remove the leading 1024 bytes in a large NSMutableData:
NSMutableData *bigData = ... // (approx 1MB of data);
UInt64 byte_shift = 1024; // skip over first 1024 bytes
UInt64 new_length = bigMutData.length-byte_shift;
NSRange moveRange = NSMakeRange(0,new_length);
[bigMutData replaceBytesInRange:moveRange
withBytes:bigMutData.bytes+1024
length:new_length];
[bigMutData setLength:new_length];
-Carl
_______________________________________________
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