I am confused why my app is crashing with this error.
I have implemented the displayLayer method (for rendering CALayer). The first time this method runs things work fine. But subsequent calls to this is when the error occurs.
The error seems to occur when the self.bgColor is being set to the context fill color. INTERESTINGLY... if I create the bgColor right before that line, things work. But as it stands, the bgColor is being created upon initialization of this class (the container of the displayLayer method).
-(void)displayLayer:(CALayer *)caLayer
{
UIGraphicsBeginImageContext(caLayer.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, self.bgColor);
CGContextFillRect(context, CGRectMake(0, 0, 320, 25));
[self drawText:context];
// get image buffer
UIImage *imageBuffer = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// set layer contents to image buffer
caLayer.contents = (id)[imageBuffer CGImage];
}