views:

161

answers:

1

I'm having some troubles with the bundle and somehow I can't save images from bundle to docs directory any more. Now I've got this error before building:

The document NSBundle.h could no be saved

It apparently compiles well. This is the kind of code I'm using:

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

Thanks for your help in advance.

+1  A: 

You should use NSString's file extensions category:

-stringByAppendingPathComponent:
-stringByAppendingPathExtension:

That will take care of any potential issues with trailing slashes, etc.

Also, you should never pass any unknown string as the format argument to any variable length function, as they could contain format specifiers. Use NSLog(@"%@", anError) instead.

retainCount