rollingcodes
rollingcodes

Reputation: 16082

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!

Upvotes: 8

Views: 6006

Answers (2)

Seamus Campbell
Seamus Campbell

Reputation: 17916

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];

Upvotes: 17

puzzle
puzzle

Reputation: 6131

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.

Upvotes: 6

Related Questions