I am currently working on a Project which is in Objective C.
I need to use Functions of Java class DataOutputStream
like writeChars
, writeLong
, flush
and some functions of ByteArrayOutputStream
Class.
Specifically, what can I use in Objective C which has the same functionality as the DataOutputStream
and ByteArrayOutputStream
class?
This is the code i need to convert into Objective C.
public static byte[] getByteArray(String key, long counter) throws IOException
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
if (key != null)
{
dos.writeChars(key);
}
dos.writeLong(counter);
dos.flush();
byte[] data = bos.toByteArray();
return data;
}