Getting a list of files in the Resources folder – iOS

You can get the path to the Resources directory like this,

NSString * resourcePath = [[NSBundle mainBundle] resourcePath];

Then append the Documents to the path,

NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"Documents"];

Then you can use any of the directory listing APIs of NSFileManager.

NSError * error;
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error];

Note : When adding source folder into the bundle make sure you select “Create folder references for any added folders option when copying”

Leave a Comment