Swapping Endianness In Objective-C? Swapping Endianness In Objective-C? objective-c objective-c

Swapping Endianness In Objective-C?


As well as the APIs already mentioned, there is CoreFoundation/CFByteOrder.h.


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.)


Have you found

Endian.h    OSByteOrder.h