I have some NSData instance with 2 bytes of different value.
Will calling getBytes: of any kind (length, range...) also advance the current position in the buffer?
Example:
NSData *data = ...; // 2 bytes data
[data getBytes:&whatever1 length:1]; // reading first byte
[data getBytes:&whatever2 length:1]; // reading first OR second byte?
Will the contents that I get on each time getBytes:length: is called be the same first byte in the NSData instance or will the first call advance the next call to read from the second byte?
Thanks!
No, it does not.
In the example it will access the same byte (first).
To access the "next" byte you'll need to use getBytes:range: but, like @hot-licks commented, NSData is immutable and therefore won't be modified.