views:

54

answers:

0

Hi,

The code below "sometimes" causes a crash (EXC_BAD_ACCESS) when run on the device. Never on the simulator.

To reproduce it I keep overlaying a modal view controller over my table view controller. It usually happens when the modal view controller is dismissed.

Any ideas why this happens?

CGContextRef context = UIGraphicsGetCurrentContext();

//set the background of the cell
[self.backgroundColor set];
CGContextFillRect(context, rect);

// get cached image
UIImage *image = [[ImageUtil sharedInstance] getImageByRouteType:route.type];
CGSize imageSize = CGSizeMake(IMAGE_WIDTH, IMAGE_WIDTH);
// DEBUGGER STOPS ON THIS NEXT LINE, image object is fine though
[image drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)];

[...]

Thanks