On Jul 14, 2014, at 11:35 AM, Ben Kennedy <b...@zygoat.ca> wrote: > On 14 Jul 2014, at 11:30 am, Carl Hoefs <newsli...@autonomy.caltech.edu> > wrote: > >>> [bigMData replaceBytesInRange:NSMakeRange(0,0) withBytes:newBytesPtr >>> length:1024]; >> >> Wow, that's damn clever! My thinking is so clunky. It never would have >> occurred to me that NSMutableData could expand (0,0) into (0,1024) out of >> thin air! Awesome! > > Well, it's basically the inverse of your first question, for which Matt Gough > already provided the answer. > > NSMutableData's method is well designed and well named because it does > exactly as it implies: replaces some range of data (whatever size) with > another chunk of data (whatever size). > > -ben > Yes, I guess it's the semantics that threw me. I was attempting to "insertBytesInRange" not "replaceBytesInRange", so I had it in my mind that the one couldn't do the other. But that's the whole purpose of the NSRange. Very cool. -Carl
_______________________________________________ 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