What is the best way to convert this java code into Objective C code??

Posted by LCYSoft on Stack Overflow See other posts from Stack Overflow or by LCYSoft
Published on 2011-02-14T06:57:08Z Indexed on 2011/02/14 7:25 UTC
Read the original article Hit count: 211

Filed under:
|
|
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 :)

© Stack Overflow or respective owner

Related posts about java

Related posts about objective-c