I have a zip file that I unzip it in a directory ‘extract’ under the Documents directory (the dir and its content is properly created). Then I would to do some stuff on each item in the new dir, dipendently if it’s a file or a dir. I use the contentsOfDirectoryAtPath method of the NSFileManager.
The problem is that the array extractedItems returns always null and I don’t know what I’m wronging.
NSString *dirnameForUnzippedData = [[NSString alloc] initWithString:@"extract"];
NSString *dirpath = [documentsDirectory stringByAppendingPathComponent:dirnameForUnzippedData];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *extractedItems = [fileManager contentsOfDirectoryAtPath:dirnameForUnzippedData error:NULL];
for (NSString *item in extractedItems) { ... }
It seems you are looking at the wrong path. Your code doesn’t use
dirpath(or yourdocumentsDirectory).As a side note, don’t forget to
releasedirnameForUnzippedData after you’re done with it – or just dodirnameForUnzippedData = @"extract";instead of the alloc/init.