I need to swap the endianness of some values and just wondered if there was anything available in Objective-C, currently I am swapping the bytes with the CStyle function below (which obviously I can reuse) I just wanted to check there was nothing specific I was missing?
float floatFlip(float inFloat) {
union {
int intValue;
float newFloat;
} inData, outData;
inData.newFloat = inFloat;
outData.intValue = CFSwapInt32BigToHost(inData.intValue);
return(outData.newFloat);
}
EDIT_001
Thanks to the pointers here I have integers sorted, whats the simplest way to swap a float?
int myInteger = CFSwapInt32BigToHost(myInteger);
(Code above updated)
float myFloat = floatFlip(myFloat);
gary