iosxcodecgcontextcgcontextdrawimage

CGContextDrawPath: invalid context 0x0


I have this code, that I think is the problem here:

CGContextRef context =  CGBitmapContextCreate(nil,
                                              routeView.frame.size.width,
                                              routeView.frame.size.height,
                                              8,
                                              4 * routeView.frame.size.width,
                                              CGColorSpaceCreateDeviceRGB(),
                                              kCGImageAlphaPremultipliedLast);

CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
CGContextSetLineWidth(context, 1.0);

from: https://github.com/kadirpekel/MapWithRoutes/tree/master/Classes

That is actually working that project with any changes, then I try to import somethings to my code and doesn't work, i get this error:

Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextSetRGBFillColor: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextSetLineWidth: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextDrawPath: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGBitmapContextCreateImage: invalid context 0x0

Solution

  • The answer is @Sohaib comment:

    Make sure your routeView is initialized properly and CGBitmapContextCreate function doesn't return nil – Sohaib Feb 5 '13 at 14:32