Is there an equivalent in Objective C to C#'s BinaryReader and BinaryWriter? For example, a BinaryReader would take an NSData* object (or a generalised stream), and would have methods such as -(uint32_t)readUnsignedInt, -(double)readDouble, etc. A BinaryWriter would be symmetrical, and would work with NSMutableData* (or a generalised stream).

有帮助吗?

解决方案

So I ended up writing a reader and writer for binary streams: https://github.com/vladimirg/objc-binary-stream-tools

其他提示

There isn't, but it is very easy to write one.

I wrote a stream reader for decoding OWON Oscilloscope binary files. See the OwStreamingDataParser class found in this github repository. Creating the writer would be the same thing, but in reverse. That should, at least, give you a start.

Note that if you are reading/writing graphs of Objective-C objects and only targeting iOS or OS X, then you can use NSArchiver.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top