开发者

What is the objective-c equivalent to Java's ByteArrayOutputStream?

开发者 https://www.devze.com 2023-01-27 03:54 出处:网络
I want to prepare a binary mess开发者_开发技巧age in memory before sending it over the network.

I want to prepare a binary mess开发者_开发技巧age 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.


The documentation for NSOutputStream tells you what you need to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消