Re: [NSMutableData resetDataRangeTo:(NSRange)range];
Re: [NSMutableData resetDataRangeTo:(NSRange)range];
- Subject: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
- From: Mike Abdullah <email@hidden>
- Date: Mon, 14 Jul 2014 19:22:14 +0100
On 14 Jul 2014, at 19:12, Carl Hoefs <email@hidden> wrote:
> Okay, now if I want to insert 1024 bytes of new data at the beginning of a populated NSMutableArray, is there a better way than this:
Yes.
[bigMData replaceBytesInRange:NSMakeRange(0,0)
withBytes:newBytesPtr
length:1024];
>
> NSMutableData *bigMData = ... // (approx 1MB of data);
> int origlength = bigMData.length;
> uint8_t *newBytesPtr = ...
> . . .
> // Shift contents over by 1024 bytes
> [bigMData replaceBytesInRange:NSMakeRange(1024,origlength)
> withBytes:bigMData.bytes
> length:origlength];
> // Add new contents to the beginning
> [bigMData replaceBytesInRange:NSMakeRange(0,1024);
> withBytes:newBytesPtr
> length:1024];
> This seems a bit messy.
_______________________________________________
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