Question

I want to prepare a binary message in memory before sending it over the network. What is the objective-c equivalent to Java's ByteArrayOutputStream?

I saw the somewhat complicated CFWriteStreamCreateWithAllocatedBuffers, and the simpler looking [[NSOutputStream alloc] initToMemory], however - I was not able to figure out how to use any of those.

A code sample that initializes an output stream, write some data into it and get the results bytes (in some form, NSData or char* or whatever) would really help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top