苹果的文档指出,通常情况下Quartz2D是线程安全的。然而,在NSOperation期间向图像上下文绘制时,我遇到了崩溃(EXC_BAD_ACCESS)。
这是我的当前设置:
UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
// drawing code
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我怀疑崩溃与当前上下文有关,因为UIGraphicsGetCurrentContext文档说明需要从主线程调用。这是正确的吗?还有其他获取图像上下文的方法吗?