Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Quartz PDF基于上下文的函数失败(偶尔),访问错误_Iphone_Objective C_Cocoa Touch_Ipad_Ios - Fatal编程技术网

Iphone Quartz PDF基于上下文的函数失败(偶尔),访问错误

Iphone Quartz PDF基于上下文的函数失败(偶尔),访问错误,iphone,objective-c,cocoa-touch,ipad,ios,Iphone,Objective C,Cocoa Touch,Ipad,Ios,当我调用此Quartz函数时,我经常会得到一个足够坏的访问: CGContextDrawPDFPage ((CGContextRef)context, (CGPDFPageRef)pageRef); 我这样称呼它: CGContextRef context = UIGraphicsGetCurrentContext(); //translate, scale CGPDFPageRef myPageRef = CGPDFDocumentGetPage ([PDFDocument sharedPD

当我调用此Quartz函数时,我经常会得到一个足够坏的访问:

CGContextDrawPDFPage ((CGContextRef)context, (CGPDFPageRef)pageRef);
我这样称呼它:

CGContextRef context = UIGraphicsGetCurrentContext();
//translate, scale
CGPDFPageRef myPageRef = CGPDFDocumentGetPage ([PDFDocument sharedPDFDocument].documentData, pageNumber);
CGContextDrawPDFPage (context, myPageRef);//BAD_ACCESS HERE
return UIGraphicsGetImageFromCurrentImageContext();//autoreleased- saved on return
//close context
两个变量都不是零,或者都已释放/自动释放

以下是来自调试器的堆栈跟踪:

有人能解释一下吗?甚至还有一些关于如何更好地调查这一问题的建议。它甚至可能不是特定于函数的。
我可能应该提到这个函数是在一个单独的线程上执行的。

检查文档中返回您的
myPageRef
,看看您是否必须保留它。

在写问题时,UIGraphicsGetImageFromCurrentImageContext和那些线程不安全的函数,这是我的问题。从iOs 4.1+开始,许多UI功能现在都是线程安全的