I am trying to copy a folder in my NSBundle which contains quite a number of images.
I tried doing it with these codes.
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentDBFolderPath = [documentsDirectory stringByAppendingPathComponent:@"Images"];
NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"Images"];
[fileManager copyItemAtPath:resourceDBFolderPath toPath:documentDBFolderPath error:&error];
Lets say there's an image in the folder named Test.png and i want to display the image on my button, it does not work!
However, if i only copied a single image from the NSBundle to NSDocumentDirectory, it works!
Example:
Changing
stringByAppendingPathComponent:@"Images"
To
stringByAppendingPathComponent:@"Test.png"
So the problem lies with copying the folder to NSDocumentDirectory!
Are my codes above incorrect?
Or it is impossible to copy folders? (Which means i have to copy files individually)