无法保存文档NSBundle.h

时间:2009-08-21 15:41:07

标签: iphone objective-c xcode filesystems bundle

我在使用捆绑包时遇到了一些麻烦,不知怎的,我无法再将图像从bundle保存到docs目录了。现在我在构建之前遇到了这个错误:

  

文件NSBundle.h不可能   保存

显然汇编得很好。 这是我正在使用的那种代码:

//Get every name from plist array and append it to the full path
for( NSString *aName in namesPackage ) {

    bundlePath = [[NSBundle mainBundle] pathForResource:aName ofType:@"png"];
    if([fileManager fileExistsAtPath:bundlePath])NSLog(@"it exists in bundle:  %@",bundlePath);
    imagePath = [NSString stringWithFormat:@"%@/%@/%@",DOCUMENTS_FOLDER,package,aName];

    [fileManager copyItemAtPath:bundlePath toPath:imagePath error:&anError];
    if(anError) NSLog([anError description]);
}   

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您应该使用NSString的文件扩展名类别:

-stringByAppendingPathComponent:
-stringByAppendingPathExtension:

这将处理拖尾斜杠等任何潜在问题。

此外,您应该永远将任何未知字符串作为格式参数传递给任何变量长度函数,因为它们可能包含格式说明符。请改用NSLog(@“%@”,anError)。