Are there any built in utilities or macros in the objective-c libraries for iOS that will allow you to convert bytes to and from integers with respect to endianess?
Please don’t tell me to use bit-shifting operations. I am trying to avoid writing custom code to do this if it already exists.
I would like the code to convert NSData* to primitive types (int, uint, short, etc) and to convert primitive types back to NSData*.
You can get the bytes from
NSDataby accessing thebytesproperty. Then just cast that to a pointer to whatever type you want. Obviously you’ll need to ensure you know the endianness and size of what is in yourNSData.e.g.