Here is the code snippet I'm using:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^
{
UIGraphicsBeginImageContextWithOptions(irect.size, YES, 0.0 );
CGContextRef context = UIGraphicsGetCurrentContext();
if (context == 0)
NSLog (@"Null Graphics Context") ;
else
NSLog (@"OK") ;
. . . .
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}) ;
I find that every other call to UIGraphicsGetCurrentContext returns NULL. I get this message on the console.
CGContextRestoreGState: invalid context 0x0. This is a serious mistake. This application or the library it uses uses an invalid context and thereby contributes to a general deterioration in the stability and reliability of the system. This notice is a courtesy: fix this problem. This will be a fatal mistake in the upcoming update.
What will call UIGraphicsGetCurrentContext to return an invalid graphics context?
source
share