views:

22

answers:

1

Using this code causes a Bus Error. Can someone point out what is wrong with it? I'm overriding a method from CALayer.

- (void) setBackgroundColor:(CGColorRef)c
{
    float *components = (float *)CGColorGetComponents(c);
    [super setBackgroundColor:[LOLColors colorWithRed:components[0] green:components[1] blue:components[2] alpha:transparencyLevel]];
}

P.S. colorWithRed:green:blue:alpha is a class method which works perfectly fine.

That's the prototype:

+ (CGColorRef) colorWithRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha
A: 

And again, figured by trial and error.

The size of *components array was smaller than 2 so I was accessing non-existent members.

Nick Brooks
I'm a terrible coder.
Nick Brooks