#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSFileManager *manager = [NSFileManager defaultManager];
//如果是相对相对路径转换为绝对路径
NSString *home = [@"/Users/tang/desktop/123" stringByExpandingTildeInPath];
NSLog(@"home: %@", home);
//列举出文件路径下的目录
NSDirectoryEnumerator *direnum = [manager enumeratorAtPath:home];
NSMutableArray *files = [NSMutableArray arrayWithCapacity:42];
NSString *filename ;
while (filename = [direnum nextObject]) {
[files addObject: filename];
// if ([[filename pathExtension] isEqualTo:@"jpg"]) {
// [files addObject: filename];
//}
}
NSEnumerator *fileenum;
fileenum = [files objectEnumerator];
for (id filePath in fileenum) {
NSLog(@"%@", filePath);
}
//while (filename = [fileenum nextObject]) {
// NSLog(@"%@", filename);
//}
}
return 0;
}