2009-08-21 78 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)。