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基础教程》

posted @ 2015-12-12 09:35  Ficow  阅读(987)  评论(0编辑  收藏  举报