CFURLCreateDataAndPropertiesFromResource失败,出现错误代码-15

CFURLCreateDataAndPropertiesFromResource失败,出现错误代码-15

问题描述:

我试图使用CGImageSourceCreateWithURL将TIFF图像引入CGImageSource。我的网址是正确的,是%20编码的,是现有文件的路径,该文件是TIFF。然而,该行:CFURLCreateDataAndPropertiesFromResource失败,出现错误代码-15

NSString *fullPath = [[[fileNames objectAtIndex:pageNum - 1] string] 
          stringByAddingPercentEscapesUsingEncoding: 
           NSUTF8StringEncoding]; 
NSString* urlStr = [NSString stringWithFormat: @"file:/%@", fullPath]; 
NSURL * url = [NSURL URLWithString: fullPath]; 

CGImageSourceRef src = CGImageSourceCreateWithURL (url, NULL); 

给了我以下错误:

Wed Aug 4 20:17:20 Brians-mini.local DocKeep[17199] <Error>: CGImageSourceCreateWithURL: CFURLCreateDataAndPropertiesFromResource failed with error code -15. 

人知道-15什么错误?或者我能找到它的地方?

感谢

ETA:我还想说,我没有这个问题,如果路径不具有在它的空间...(文件名中的空格是耶和华所憎恶,但我想我们必须和他们一起住...... B-)

试试这个:

NSString *fullPath = [[fileNames objectAtIndex:pageNum - 1] string]; 
CFStringRef fullPathEscaped = CFURLCreateStringByAddingPercentEscapes(NULL, 
      (CFStringRef)pdfPath, NULL, NULL,kCFStringEncodingUTF8); 

CFURLRef url = CFURLCreateWithString(NULL, fullPathEscaped, NULL); 
CGImageSourceRef src = CGImageSourceCreateWithURL (url, NULL); 
+0

这对我有用,fileURLWithPath:似乎也似乎封装了应用程序资源路径。 – 2016-02-24 19:57:38

错误代码-15是被kCFURLImproperArgumentsError

更多信息在Apple documentation for Core Foundation URL Access Utilities Reference

请勿为此使用+URLWithString:。而是使用专用内存+fileURLWithPath: