Posted By

BenClayton on 04/20/10


Tagged


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

oakdragon
umang_nine
rvachere
Tintenklecks
cnathan


get all / list all folders in directory


 / Published in: Objective C
 

  1. +(NSArray*)arrayOfFoldersInFolder:(NSString*) folder {
  2. NSFileManager *fm = [NSFileManager defaultManager];
  3. NSArray* files = [fm directoryContentsAtPath:folder];
  4. NSMutableArray *directoryList = [NSMutableArray arrayWithCapacity:10];
  5.  
  6. for(NSString *file in files) {
  7. NSString *path = [folder stringByAppendingPathComponent:file];
  8. BOOL isDir = NO;
  9. [fm fileExistsAtPath:path isDirectory:(&isDir)];
  10. if(isDir) {
  11. [directoryList addObject:file];
  12. }
  13. }
  14.  
  15. return directoryList;
  16. }

Report this snippet  

You need to login to post a comment.