On 14 Jul 2014, at 19:12, Carl Hoefs <newsli...@autonomy.caltech.edu> 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 (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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to