views:

164

answers:

1

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?

+2  A: 

It does it automatically. From the documentation:

An enumeration is recursive, including the files of all subdirectories, and crosses device boundaries. An enumeration does not resolve symbolic links, or attempt to traverse symbolic links that point to directories.

Dave DeLong