• 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: adding byte by byte to a NSMutableData object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: adding byte by byte to a NSMutableData object


  • Subject: Re: adding byte by byte to a NSMutableData object
  • From: Greg Titus <email@hidden>
  • Date: Sat, 4 Oct 2003 14:15:25 -0700

On Saturday, October 4, 2003, at 01:43 PM, Ben Dougall wrote:

On Saturday, October 4, 2003, at 07:58 pm, Dustin Voss wrote:

The two fastest ways to add bytes to an NSMutableData, if the bytes aren't already in an NSData object, seem to be addBytes:length:, or increaseLengthBy: and set the new bytes with mutableBytes.

thanks for the reply.

even on a single byte by single byte basis?

i'm reading a small chunk of data from the first NSData object and changing it, then sticking that onto the end of the second NSMutableData object (attempting to decode ASCII85 data) so a direct pointer way seemed a better way but i wasn't sure if the way i showed even worked. i know *think* it may well have been ok and it something else that was going wrong.

For efficiency the direct pointer way is better. You may want to check out the code in OmniFoundation's NSData-OFExtensions.m, which has a -initWithASCII85String: method for converting ASCII85 into an NSData object. We use an OFDataBuffer, which is some fast inline functions and a couple of pointers wrapped around an NSMutableData object.

As for your sample code, it ought to work just fine. (Although you'll need to have more complicated code with the length of the newData object in your real ASCII85 decoder, since it generally won't end up being the same length as the oldData. Otherwise you'd end up with extra garbage at the end of your result.)

Hope this helps,
- Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: adding byte by byte to a NSMutableData object
      • From: Ben Dougall <email@hidden>
References: 
 >Re: adding byte by byte to a NSMutableData object (From: Ben Dougall <email@hidden>)

  • Prev by Date: Printing processing two notifications?
  • Next by Date: prevent cell highlight for NSTableView
  • Previous by thread: Re: adding byte by byte to a NSMutableData object
  • Next by thread: Re: adding byte by byte to a NSMutableData object
  • Index(es):
    • Date
    • Thread