• 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: Matt Gough <email@hidden>
  • Date: Sat, 12 Jul 2014 21:51:13 +0100

don’t you just want:

[bigData replaceBytesInRange:NSMakeRange(0, 1024) withBytes:NULL length:0];

??

I am sure NSMutableData is well optimized for shunting its contents around internally.

Matt


On 12 Jul 2014, at 20:36, Carl Hoefs <email@hidden> wrote:

> 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


_______________________________________________

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>
    • Re: [NSMutableData resetDataRangeTo:(NSRange)range];
      • From: Carl Hoefs <email@hidden>
References: 
 >[NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)

  • Prev by Date: Re: Issue with -[NSOutlineView autosaveExpandedItems] - SOLVED
  • Next by Date: Re: having both cell based and view based outline views in one project
  • Previous by thread: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Next by thread: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Index(es):
    • Date
    • Thread