Re: NSData. add 6 bytes to NSData

2009-07-04 Thread Greg Guerin
Carlo Gulliani wrote: typedef struct mrim_packet_header_t { u_long magic; Your use of u_long as a 32-bit value will likely fail if your code is ever compiled for 64-bit. You should use the typedef'ed names that have an explicit size-number in them, like uint32_t, uint64_t. NSM

Re: NSData. add 6 bytes to NSData

2009-07-04 Thread Adam R. Maxwell
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

Re: NSData. add 6 bytes to NSData

2009-07-04 Thread Scott Andrew
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 firs

Re: NSData. add 6 bytes to NSData

2009-07-04 Thread Carlo Gulliani
thanks for your reply, could you show me simple example how to add binary data to existing data and also to add header of 2 bytes i've been trying to use buffer but i have a troubles with result my code: #define PROTO_VERSION_MAJOR 1 #define PROTO_VERSION_MINOR 7 #define PROTO_VERSION

Re: NSData. add 6 bytes to NSData

2009-07-04 Thread Peter Mulholland
Hello Carlo, Saturday, July 4, 2009, 12:47:31 PM, you wrote: > Hi, everybody, I need to add 6 bytes to my NSData > steps: > 1. write into NSData > NSData *data = [NSData dataWithBytes:(const char*)&packet > length:sizeof(packet)]; > 2. read from NSData > 3. In loop i need to add 6 bytes > 4.