Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting iPhone mainBundle Files

I dont know the exact code i need to retrieve all of the filenames of the resources in my iphone apps mainBundle. if i could have some kind of code like:

  NSArray *array = [[NSBundle mainBundle] getAllResourceFilenames];

it would be helpful. thanks inadvanced for any help!

like image 387
NoodleOfDeath Avatar asked Aug 07 '10 00:08

NoodleOfDeath


2 Answers

You should look at the SDK documentation for NSFileManager, but this will get you started:

NSString *path = [[NSBundle mainBundle] resourcePath];
NSFileManager *fm = [NSFileManager defaultManager];

NSError *error = nil;

NSArray *directoryAndFileNames = [fm contentsOfDirectoryAtPath:path error:&error];
like image 162
Seamus Campbell Avatar answered Oct 20 '22 01:10

Seamus Campbell


You can get the resources path of the main bundle

[[NSBundle mainBundle] resourcePath];

and then simply use the regular NSFileManager methods to get its contents.

like image 35
puzzle Avatar answered Oct 20 '22 01:10

puzzle