在緩存目錄中保存了圖片文件,然後再從目錄中提取出來。
下面的代碼是獲取保存的全部文件:
[fileManager contentsOfDirectoryAtPath:pathForCacheDirectory error:&error]
怎麼樣從這裡面單獨提取出圖片文件呢?圖片文件格式不限。
CFStringRef fileExtension = (CFStringRef) [file pathExtension];
CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
if (UTTypeConformsTo(fileUTI, kUTTypeImage)) NSLog(@"It's an image");
else if (UTTypeConformsTo(fileUTI, kUTTypeMovie)) NSLog(@"It's a movie");
else if (UTTypeConformsTo(fileUTI, kUTTypeText)) NSLog(@"It's text");
else NSLog(@"It's audio");