How to get a 32 bit number in objective c when an byte array is passed to it, similarly as in java where,
ByteBuffer bb = ByteBuffer.wrap(truncation);
return bb.getInt();
Where truncation is the byte array.
It returns 32 bit number.. Is this possible in objective c?
If the number is encoded in little-endian within the buffer, then use:
If the number is encoded in big-endian within the buffer, then use:
UPDATE If you are using data created on the same host then endianness is not an issue, in which case you can use a
unionas a bridge between the buffer and integers, which avoids some unpleasant casting: