Cocoa and listing folder contents...

konan

Registered
How do I retreive the contents of a folder using Cocoa? In windows, there is the findfirst() and function retreive the first file in the folder, then the rest can be retreived via the findnext() function.

I was able to do this in OS X with the following bit

system("ls Folder/ > Listing.txt");
then I read the file Listing.txt to get the file names.

This is a little crude and I'd rather find a more elegant way to do it.

Again, any push in the right direction would be greatly appreciated
Konan
 
See NSFileManager . Methods you would use are directoryContentsAtPath. This will return an array of the files, so get the first file in the directory by calling [myArray objectAtIndex:0]
 
Back
Top