Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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 CGPDFDocumentCreateWithURL崩溃_Iphone_Objective C_Core Graphics - Fatal编程技术网

Iphone CGPDFDocumentCreateWithURL崩溃

Iphone CGPDFDocumentCreateWithURL崩溃,iphone,objective-c,core-graphics,Iphone,Objective C,Core Graphics,我获得了对该代码的EXC\u BAD\u访问权限: NSURL *pdfURL = [NSURL URLWithString:path]; pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); CFRelease(pdfURL); “path”只是我正在从documents目录加载的文件的NSString路径。我碰巧确保了路径是正确的。我也在模拟器上运行,但我不明白为什么在这种情况下会有不同 知道坠机的原因吗 谢谢不要发布pdf

我获得了对该代码的EXC\u BAD\u访问权限:

    NSURL *pdfURL = [NSURL URLWithString:path];
  pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
  CFRelease(pdfURL);
“path”只是我正在从documents目录加载的文件的NSString路径。我碰巧确保了路径是正确的。我也在模拟器上运行,但我不明白为什么在这种情况下会有不同

知道坠机的原因吗


谢谢

不要发布pdfURL。URLWithString:返回自动释放的对象。

如果
path
是本地文件系统路径,则应使用
fileURLWithPath:
,而不是
URLWithString:
(具体采用URL字符串)。