NSFileManager相关
枚举相同格式的文件:
You can achieve this pretty easily with the help of NSPredicate, like so:
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];NSFileManager *fm = [NSFileManager defaultManager];NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil];NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self ENDSWITH '.jpg'"];NSArray *onlyJPGs = [dirContents filteredArrayUsingPredicate:fltr];
+(BOOL)fileExistsAtAbsolutePath:(NSString*)filename { BOOL isDirectory; BOOL fileExistsAtPath = [[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDirectory]; return fileExistsAtPath && !isDirectory;}
+(BOOL)directoryExistsAtAbsolutePath:(NSString*)filename { BOOL isDirectory; BOOL fileExistsAtPath = [[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDirectory]; return fileExistsAtPath && isDirectory;}