Objective c CFURLCreateDataAndPropertiesFromResource失败,错误代码为-15
我正在尝试使用CGImageSourceCreateWithURL将TIFF图像导入CGImageSource。我的URL是正确的,是%20编码的,是现有文件的路径,该文件是TIFF。然而,该行:Objective c CFURLCreateDataAndPropertiesFromResource失败,错误代码为-15,objective-c,nsurl,cgimagesource,Objective C,Nsurl,Cgimagesource,我正在尝试使用CGImageSourceCreateWithURL将TIFF图像导入CGImageSource。我的URL是正确的,是%20编码的,是现有文件的路径,该文件是TIFF。然而,该行: NSString *fullPath = [[[fileNames objectAtIndex:pageNum - 1] string] stringByAddingPercentEscapesUsingEncoding:
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.
Wed Aug 4 20:17:20 Brians-mini.local dockep[17199]:CGImageSourceCreateWithURL:CFURLCreateDataAndPropertiesFromResource失败,错误代码为-15。
有人知道-15是什么错误吗?或者我在哪里能找到它
谢谢
埃塔:我还应该提到,如果路径中没有空格,我就不会有这个问题。。。(文件名中的空格是上帝所憎恶的,但我想我们必须与之共存……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);
试试这个:
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);
错误代码-15为kCFURLImproperArgumentsError
有关详细信息,请访问。错误代码-15是KCFURLIProperargumentsError
有关详细信息,请访问。不要为此使用
+URLWithString:
。相反,请使用专门构建的+fileURLWithPath:
不要为此使用+URLWithString:
。相反,使用专门构建的+fileURLWithPath:
这对我来说很有效,fileURLWithPath:似乎也封装了应用程序资源路径。这对我来说很有效,fileURLWithPath:似乎也封装了应用程序资源路径。