在缓存目录中保存了图片文件,然后再从目录中提取出来。
下面的代码是获取保存的全部文件:
[fileManager contentsOfDirectoryAtPath:pathForCacheDirectory error:&error]
怎么样从这里面单独提取出图片文件呢?图片文件格式不限。
在缓存目录中保存了图片文件,然后再从目录中提取出来。
下面的代码是获取保存的全部文件:
[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");