2009-08-21 75 views
0

我遇到了一些麻烦与捆绑,不知何故我不能保存图像从捆绑到docs目录更多。现在我得到这个错误之前建设:NSBundle.h文件无法保存

文档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]); 
} 

感谢您的帮助提前。

+0

没关系,我改变了NSBundle头文件中的内容,Xcode试图保存它 – Carlos 2009-08-21 16:21:29

+0

你看到了什么样的运行时错误和/或NSLog输出? – fbrereto 2009-08-21 16:44:39

回答

1

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

-stringByAppendingPathComponent: 
-stringByAppendingPathExtension: 

这会照顾任何潜在的问题尾随斜线等

此外,你应该从未通过任何未知的字符串作为format参数指向任何可变长度函数,因为它们可能包含格式说明符。改用NSLog(@“%@”,anError)。