0

I'm having the hardest time getting this to work. I'm trying to copy a folder from my bundle to the documents directory.

the folder I'm trying to find is here:

...app/Resources/12/(a bunch of jpgs)

NSString *myPath = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"12"];
NSLog(@"%@",myPath);/// returns "..../MyApp.app/12"

NSArray *arrayOf12s = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:myPath error:nil];

NSLog(@"%@",arrayOf12s);     ////always returns NULL

1 Answer 1

2

How about using the NSError argument in -contentsOfDirectoryAtPath:error: call?

NSString *myPath = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"12"];
NSLog(@"%@",myPath);/// returns "..../MyApp/12"

NSError *error = nil;
NSArray *arrayOf12s = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:resourceDBFolderPath error:&error];

if (error)
   NSLog(@"Error: %@", [error localizedDescription]);

NSLog(@"%@",arrayOf12s);     ////always returns NULL

It might shine some light on the cause...

3
  • All it gives is: Error: Operation could not be completed. (Cocoa error 260.)
    – Brodie
    Oct 29, 2010 at 16:52
  • What is 'resourceDBFolderPath' set to?
    – westsider
    Oct 29, 2010 at 17:02
  • Also, have you seen this <stackoverflow.com/questions/418680/…>? It might help with including entire directory into your app bundle - as opposed to just the directory's contents.
    – westsider
    Oct 29, 2010 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.