• 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: Ben Dougall <email@hidden>
  • Date: Sun, 5 Oct 2003 15:00:47 +0100

On Saturday, October 4, 2003, at 10:15 pm, Greg Titus wrote:


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.)

yup, i've just downloaded and had a look at that function - looks very useful. thanks very much. i think my code might be nearly there though, but i'm not sure.


off topic q about ASCII85 data: ASCII85 data should only contain the particular ASCII85 characters ('!'...'u' 'z' and '~>') right? it's just that the apparent ASCII85 data i have that i'm using to test my ASCII85 decoding code on appears in BBEdit just as binary data does - as in lots of characters that fall outside (and inside) the ASCII85 range. so basically, this data cannot be ASCII85?

just to reiterate that question, and it's probably a bit silly but i just want to absolutely check: does ASCII85 data look like you'd expect it to look like (restricted to just those particular characters) and not like how binary usually appears?
(it must do, as that's the whole point of encoding data into a printable ascii characters i think)
_______________________________________________
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.
References: 
 >Re: adding byte by byte to a NSMutableData object (From: Greg Titus <email@hidden>)

  • Prev by Date: Re: stop and wait
  • Next by Date: Re: stop and wait
  • Previous by thread: Re: adding byte by byte to a NSMutableData object
  • Next by thread: adding byte by byte to a NSMutableData object
  • Index(es):
    • Date
    • Thread