Swapping Endianness In Objective-C?
You're looking for OSSwapInt32()
(or OSSwapInt16()
, OSSwapInt64()
, etc.). See OSByteOrder.h.
Also note that these are non-portable. If you are only converting to big-endian you may want to consider using something like htonl()
, which is included in the standard library <arpa/inet.h>
. (Unfortunately, though, there is no standard library for simply swapping back-and-forth.)
As well as the APIs already mentioned, there is CoreFoundation/CFByteOrder.h.
Have you found
Endian.h
OSByteOrder.h