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 ?
Asked
Active
Viewed 388 times
-2
-
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 Answers
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"

Fran Martin
- 2,369
- 22
- 19
-
-
check you have your folder cat inside of your project in Finder. This code should works – Fran Martin Feb 26 '14 at 10:13
-
checked it is right there.. in fact I have added that folder from project to the bundle, so that is not the problem – Dhaval H. Nena Feb 26 '14 at 10:24
-
ohh.. just forgot to add reference.. THANK YOU SO MUCH.. :) @SonGoku68 – Dhaval H. Nena Feb 26 '14 at 12:15