-2

Have created one folder say 'cat' in bundle which contains images. Now I need to load all that images in an array. how to do that programmatically ?

Amar
  • 13,202
  • 7
  • 53
  • 71
Dhaval H. Nena
  • 3,992
  • 1
  • 37
  • 50
  • NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"cat" ofType:nil]; – Dhaval H. Nena Feb 26 '14 at 09:32
  • This is already answered in [this post][1] [1]: http://stackoverflow.com/questions/499673/getting-a-list-of-files-in-a-directory-with-a-glob – Richard Ruiter Feb 26 '14 at 09:32
  • @RichardRuiter ya but is gives the list of all files in the bundle.. but i need only the files within specific folder. can you please help me in that? – Dhaval H. Nena Feb 26 '14 at 09:41

1 Answers1

0

Try this

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"cat"];
NSArray *fileList = [fileManager contentsOfDirectoryAtPath:resourceDBFolderPath error:&error];

Edit:

Your folder must be added by reference. Drag your folder into your project in xCode and select "Create folder references for any added folders"

enter image description here

Fran Martin
  • 2,369
  • 22
  • 19