• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NSMutableData resetDataRangeTo:(NSRange)range];
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: [NSMutableData resetDataRangeTo:(NSRange)range];
      • From: Carl Hoefs <email@hidden>
References: 
 >[NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Matt Gough <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)

  • Prev by Date: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Next by Date: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Previous by thread: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Next by thread: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Index(es):
    • Date
    • Thread