get all / list all folders in directory


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.