Gold Challenge: gradient trouble


#1

I tried and succeeded to do the challenge. But it was not perfect. There was some odd yellow in the middle of the gradient.
Now when I looked into the solution provided by BigNerdRanch itself, they used 8(!) Components to make a gradient, but they also used CGColorSpaceCreateDeviceRGB, and the CGColorSpaceGetNumberOfComponents method returns 3 for the created color space. That means, 6 components should be enough! With 4 components per color, it worked perfectly.
I´m completely confused with this. Does the ColorSpace not know that its colors actually have an alpha value, or what is my mistake?


#2

No one else, who recognized this?


#3

Yes that tripped me up too - it seems CGColorSpaceGetNumberOfComponents ignores the alpha. From the documentation:

CGColorSpaceGetNumberOfComponents

[snip]

Return Value
The number of color components in the specified color space, [i]not including the alpha value[/i]. For example, for an RGB color space, CGColorSpaceGetNumberOfComponents returns a value of 3.