What is the best way to convert this java code into Objective C code??
- by LCYSoft
public byte[] toBytes() {
size = 12;
ByteBuffer buf = ByteBuffer.allocate(size);
buf.putInt(type.ordinal());//type is a enum
buf.putInt(id);
buf.putInt(size);
return buf.array();
}
@Override
public void fromBytes(byte[] data) {
ByteBuffer buf = ByteBuffer.allocate(data.length);
buf.put(data);
buf.rewind();
type = MessageType.values()[buf.getInt()];
id = buf.getInt();
size = buf.getInt();
}
Thanks in advance :)