I have an original NSData type which contains let’s say 100 bytes. I want to get 2 other NSData types. The first containing the first 20 bytes of the 100, and the second one containing the other 80.
They should be copied from the original NSData. Sorry if I wasn’t so clear, but I’m pretty new with Objective-C.
I have an original NSData type which contains let’s say 100 bytes. I want
Share
You can use
NSData‘s-(NSData *)subdataWithRange:(NSRange)range;to do that.From your example, here is some code :
Of course, the ranges are immediate here, you will probably have to do calculations, to make it work for your actual code.