iOS 查找文件、遍历文件系统
NSFileManager *manager = [NSFileManager defaultManager]; NSString *home = [@"~" stringByExpandingTildeInPath]; NSMutableArray *files = [NSMutableArray arrayWithCapacity:42]; NSString *filename; for (filename in [manager enumeratorAtPath:home]) { if ([[filename pathExtension]isEqualToString:@"m"]) { [files addObject:filename]; } } for (filename in files) { NSLog(@"%@",filename); }
源码来自《Objective-C基础教程》
Stay hungry,stay foolish.