views:

182

answers:

1

Hi, I am developing an application in cocoa.I need to search all songs in selectyed folder.I used "subpathsAtPath" to get all the components in selected folder. This works fine if the user selects a particular folder like /User/Music.But if the user selects root directory like "/" then this method hangs .Is there any way to resolve this problem. Thanks in advance.....

+2  A: 

As kent said, it's unlikely this method hangs, it just takes a long time to execute and blocks further execution in the thread until it returns.

Consider using enumeratorAtPath:. It uses an NSDirectoryEnumerator and gives you one directory at a time. That will eliminate the need for creating a very large array, which is costly memory-wise. I also makes it easier to break up your work into chunks (NSOperations?) so you can push it off to another thread, which would probably be a good idea, considering the amount of time it will take to finish. NSDirectoryEnumerator also gives you some control over the enumeration, i.e. you can call -skipDescendents [sic] to prune enumeration tree.

kperryua