What's the best way to consume the bytes of NSData?

131 views Asked by At

I'd like to parse some binary data. In Java I would use ByteBuffer class, which has really nifty methods like getInt(), getChar(), etc. which will return you the correct length of data, and advance the (internal) "read head".

The closest I could find in Swift is NSInputStream, which requires you manually manage a buffer, set the number of bytes to read, ensure the correct amount was read, etc. It's quite clunky. Are there any better APIs I'm overlooking?

0

There are 0 answers