我正在尝试使用CGImageSourceCreateWithURL将TIFF图像引导到CGImageSource中。我的网址是正确的,是%20编码,是现有文件的路径,该文件是TIFF。但是,行:
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 - )
答案 0 :(得分:3)
请勿使用+URLWithString:
。而是使用专门构建的+fileURLWithPath:
答案 1 :(得分:2)
试试这个:
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);
答案 2 :(得分:0)
错误代码-15是 kCFURLImproperArgumentsError 。
Apple documentation for Core Foundation URL Access Utilities Reference的更多信息。