I am having a predicament that's very similar to the one described in this SO thread. I read through every answer on that thread and was unable to find any that solved my problem. I've narrowed down my problem to 4 lines inside of the function below. Each of the 4 lines outputs several lines of errors, all of which I've listed below (I've removed duplicates).
I have tried moving [path closePath];
below those 4 lines, but it doesn't change anything. I also set a breakpoint before the first line and manually went through the function line by line, and it's just those 4 lines that are causing havoc.
As seems to be a trend with this issue, everything renders exactly as it should, but it floods the console with these kinds of messages.
Any help would be much appreciated, and I'd be glad to provide any more information and updates.
Function:
-(CAShapeLayer *)lineBetweenPoint:(CGPoint)start andPoint:(CGPoint)end {
//Draw the first circle
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:start radius:kLineEndRadius startAngle:0 endAngle:DEGREES_TO_RADIANS(360) clockwise:TRUE];
//Add the line
[path moveToPoint:start];
[path addLineToPoint:end];
[path moveToPoint:end];
//Draw the second circle
[path addArcWithCenter:end radius:kLineEndRadius startAngle:0 endAngle:DEGREES_TO_RADIANS(360) clockwise:TRUE];
//Close the path and set the coloring
[path closePath];
/*The following 4 lines cause problems*/
[[UIColor blueColor] setStroke]; /*CAUSES PROBLEM*/
[[UIColor blueColor] setFill]; /*CAUSES PROBLEM*/
[path stroke]; /*CAUSES PROBLEM*/
[path fill]; /*CAUSES PROBLEM*/
//Create a shape layer
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [path CGPath];
shapeLayer.strokeColor = [kLineColor CGColor];
shapeLayer.lineWidth = kLineWidth;
shapeLayer.fillColor = [kLineColor CGColor];
//Return the layer
return shapeLayer;
}
Log output:
: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetLineWidth: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetLineJoin: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetLineCap: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetMiterLimit: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
You're mixing your API. When you use a CAShapeLayer you don't actually do the drawing yourself, you just configure the object and let the CoreAnimation render server do the drawing. With CoreGraphics you do your drawing in-process into a CGContextRef. Your issue here is that CGContextRef's need to be created (which happens automatically in -[UIView drawRect:]). You'd do this using one of the UIGraphicsBeginImageContext… usually, but here you don't actually want CG, you want CA. So just omit those four lines and make sure your CAShapeLayer is correctly configured and you'll be good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With