Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.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
Ios CGPDFDocumentCreateWithURL在任何PDF文件上返回nil_Ios_Swift_Pdf - Fatal编程技术网

Ios CGPDFDocumentCreateWithURL在任何PDF文件上返回nil

Ios CGPDFDocumentCreateWithURL在任何PDF文件上返回nil,ios,swift,pdf,Ios,Swift,Pdf,我不明白为什么*CGPDFDocumentCreateWithURL*返回零。该文件没有加密,没有密码,是一个简单的pdf文本内容。是什么原因造成的 var pdfDoc: CGPDFDocument! pdfDoc = CGPDFDocumentCreateWithURL(url)// the value is nil even though url and pdf file are valid let pdfCatalog=CGPDFDocumentGetCatalog(pdfDoc)

我不明白为什么*CGPDFDocumentCreateWithURL*返回零。该文件没有加密,没有密码,是一个简单的pdf文本内容。是什么原因造成的

var pdfDoc: CGPDFDocument!

pdfDoc = CGPDFDocumentCreateWithURL(url)// the value is nil even though url and pdf file are valid
let pdfCatalog=CGPDFDocumentGetCatalog(pdfDoc)

请注意,该文件确实存在且url有效

通过在路径中添加“file://”解决了问题

通过在路径中添加“file://”解决了该问题

url是包含pdf文件路径的CFURLRef。我也尝试过使用CFURL,结果仍然为零。运行时的值是多少?在运行时,它包含pdf的路径(例如:Users/./mytestpdf.pdf)。通过在路径中添加“file:///”解决了问题。url是一个CFURLRef,包含pdf文件的路径。我也尝试过使用CFURL,结果仍然为零。运行时的值是多少?在运行时,它包含pdf的路径(例如:Users/./mytestpdf.pdf)。通过添加“file://”解决了此问题到路径。听起来好像您实际上没有从文件路径字符串生成NSURL。听起来好像您实际上没有从文件路径字符串生成NSURL。