Hi!
I think(*) you can use "%a" to print the hexadecimal representation of a floating point number. This prints the floating point number exactly, down to the last bit in the mantissa. It looks like 0x0.3p10, where 0x0.3 is the "significant" part and "p10" the binary exponent, and it represents the number 0x0.3 * 2^10.
In the tradition of NSTRACE, you can define a macro for the format string (to ensure that all functions that print colors use the same format). For example:
#define NSTRACE_FMT_RGB "(R:%a G:%a B:%a)"
And another to push the arguments:
#define NSTRACE_ARG_RGB(color) (color).redComponent, (color).greenComponent, (color).blueComponent
With this, you should be able to print the color values ergonomically using:
NSTRACE("The colors are " NSTRACE_FMT_RGB, NSTRACE_ARG_RGB([background_color colorUsingDefaultColorSpace]));
To make this even shorter, you can define the macro "NSTRACE_RGB" along the lines of "NSTRACE_SIZE" and "NSTRACE_POINT".
* Currently, I can't test this, as I have no mac nearby.
-- Anders