I am currently doing a lot of data wrangling. I ingest a lloonngg NSData byte streams and then parse that data. The parsing is trivial. However, I have to simulate consumption of the data as I parse via not particularly elegant bookkeeping. Here is what a typical method looks like in the category of NData I have implemented:
// Grab a little-endian 32-bit number - (uint32_t)getInt32OffsetIncrement:(NSUInteger *)offset {
uint32_t unused;
NSRange myRange = NSMakeRange(*offset, sizeof(unused));
[self getBytes:&unused range:myRange];
*offset += sizeof(unused);
return CFSwapInt32LittleToHost(unused);
}
As you can see, I retrieve the data and then advance to NSRange "pointer" into the data stream. When I'm done I have consumed the entire data stream.
Have I overlooked any methods on NSData that can simultaneously retrieve data and advance a pointer along the length of the data stream?
Cheers, Doug