I need to change the header informations of a file in document folder.
What is the most recommended way to read and write back binary data?
- How to read the data from document folder binary to array / stream
- How to write the data back from array / stream to local iPad document folder?

This one is hard to answer without you being a little more specific, but the most efficient way to do this would arguably be to not change the file at all.
Since we’re talking about iOS, there is no file-system-level access to those documents apart from your application itself. So why not save the additional/customized header data that you want to associate with your files in an application-wide meta-data-store (like e.g. iTunes or iPhoto do) and interleave them with the actual file headers during exports only?
Regardless of that, I don’t really see a compelling reason to drop down to the C-level file functions to change those data:
NSInputStreamprovides you with streaming file reading-access andNSOutputStreamcan be used to stream data to a file.If you go with my suggestion from above you’d likely end up with an API like this:
Assuming ARC and not knowing what you have to do to interleave the additional metadata with the original, here is what the boilerplate part of the implementation might look like.
The beef would clearly be in the part that I don’t show here: implementation of the delegate for the
rawDataStreamwhere you’d consume the data from the original file, interleaving the headers with your additional information.Although this should probably be factored out into a separate class, I’ve just implied that the data-store implements the
NSStreamDelegatecallbacks accordingly.After the headers you’d just pass through the rest of the file…