NSDirectoryEnumerator And Subfolders

Posted by Matthew Roberts on Stack Overflow See other posts from Stack Overflow or by Matthew Roberts
Published on 2010-05-08T13:23:47Z Indexed on 2010/05/08 13:28 UTC
Read the original article Hit count: 216

Filed under:
|
|

I have an iPhone app that searches a folder, collates an an array of all the audio files, and lets them be played back. The problem is that if there is a subfolder within the folder I am searching, it will just skip over it/not go into its contents.

My code is as follows:

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths objectAtIndex:0];
 NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager] enumeratorAtPath:documentsDirectory];

 NSString *pname;

 while (pname = [direnum nextObject])
{
      [musicArray addObject:[pname stringByDeletingPathExtension]];
}

What I want to do is continue to search its subfolders, how would I go about doing that?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about cocoa