0

バンドルに問題があり、バンドルから 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]);
}   

事前にご協力いただきありがとうございます。

4

1 に答える 1

1

NSStringのファイル拡張子カテゴリを使用する必要があります。

-stringByAppendingPathComponent:
-stringByAppendingPathExtension:

これにより、末尾のスラッシュなどの潜在的な問題が処理されます。

また、フォーマット指定子が含まれている可能性があるため、不明な文字列をフォーマット引数として可変長関数に渡さないでください。代わりにNSLog(@ "%@"、anError)を使用してください。

于 2009-08-21T18:53:34.630 に答える