• 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: NSData. add 6 bytes to NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData. add 6 bytes to NSData


  • Subject: Re: NSData. add 6 bytes to NSData
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Sat, 04 Jul 2009 11:38:09 -0700


On Jul 4, 2009, at 10:56 AM, Scott Andrew wrote:

In all honesty the easiest way is to do it in C. Add a 4 byte variable to the top of your packet header.. When building the packet set it to 0.. That solves your problem of getting data into the packet.

But if you want to add something to the beginning, using NSMutableData, you have to first create the NSMutableData packet with 4 bytes of 0s then call [data appendBytes].. So something like so (not perfect)..

Maybe I missed your point, but you can easily insert bytes in an NSMutableData. Check the documentation for -[NSMutableData replaceBytesInRange:withBytes:length:].


On Jul 4, 2009, at 9:23 AM, Carlo Gulliani wrote:

NSMutableData *data = [NSData dataWithBytes:&packet length:sizeof (packet)];

Note that this is /not/ an NSMutableData, in spite of the declaration, since you've used NSData to create it. Use [NSMutableData dataWithBytes:length:] to create a mutable data instance.


--
Adam

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Re: NSData. add 6 bytes to NSData (From: Carlo Gulliani <email@hidden>)
 >Re: NSData. add 6 bytes to NSData (From: Scott Andrew <email@hidden>)

  • Prev by Date: Re: [Moderator] Re: Securely limit the running an application by serial number
  • Next by Date: Re: NSData. add 6 bytes to NSData
  • Previous by thread: Re: NSData. add 6 bytes to NSData
  • Next by thread: Re: NSData. add 6 bytes to NSData
  • Index(es):
    • Date
    • Thread