Reputation: 10351
What's the "right way" to read in every file from a directory on OS X using Cocoa? I need to get the filename of each file and then I need to pull it's contents in to one NSString.
Upvotes: 1
Views: 124
Reputation: 1795
Get an enumerator for the path in question using the NSFileManager:
NSDirectoryEnumerator* enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path];
Then call nextObject on the enumerator in a loop until it returns nil.
Upvotes: 0