Search code examples
iosobjective-cnsdata

How can I read rest of bytes after 24 bytes from a NSData variable in objective c


How to read rest of bytes after 24 bytes from a NSData variable in objective c?


Solution

  • You can use the subdataWithRange: method of NSData to get an NSData object with the data after the first 24 bytes.

    You would do something like:

    NSData *newData = [data subdataWithRange:NSMakeRange(24, [data length] - 24)];
    

    There is also the getBytes:range: method that returns the bytes in a buffer.