文档介绍:<A > //1. 创建 Album 对象给对象添加 name 和 imagepaths 的属性***@property ( nonatomic , retain ) NSString *albumName; ***@property ( nonatomic , retain ) NSMutableArray *imagePaths; <> //1. 获取文件夹下所有的文件(文件夹和文件) NSArray *fileNames = [[ NSFileManager defaultManager ] contentsOfDirectoryAtPath :path error : nil ]; for ( NSString *fileName in fileNames) { if (![fileName hasPrefix : @"." ]){ //如果判断条件进来说明是文件夹 Album *album = [[ Album alloc ] init ]; album. albumName = fileName; NSString *directoryPath = [path ponent :fileName]; //子文件夹下面所有的文件名称 NSArray *imageNames = [[ NSFileManager defaultManager ] contentsOfDirectoryA tPath :directoryPath error : nil ]; // .JPG .png 等。 for ( NSString *imageName in imageNames) { NSLog ( @"%@" ,imageName); if ([imageName hasSuffix : @"jpg" ]||[imageName hasSuffix : @"JPG" ]||[imageName hasSuffix : @"png" ]) { [album. imagePaths addObject :[directoryPath ponent :imageName]]; }} [albums addObject :album]; }} return albums; <> //2. 创建 Utils ????( NSMutableArray *)getAlbumsByDirectoryPath:( NSStri ng *)path; <> //2. 1?????文件夹??获取所有 Album 的???( NSMutableArray *)getAlbumsByDirectoryPath:( NSString *)path{ NSMutableArray *albums =[ NSMutableArray array ]; < ?ie? > //?. ?????面????? Utils ?面的??获取 albums 的?? self . albums =[ Utils getAlbumsByDirectoryPath : @"/Users /mac/Des?top/ 图片" ]; < ?ie? > //?. ?? albums ???面的???? t