通过文件后缀判断属于那种UTI类型
涉及的核心知识点
参考大神文章
传送门1:https://blog.csdn.net/heroguo_jp/article/details/51134308
传送门2:https://www.cnblogs.com/haibosoft/p/4180587.html
涉及的核心类库
#import <MobileCoreServices/MobileCoreServices.h>
代码实现
NSString *fileExtension = [fileURL pathExtension];
NSString *fileUTI = [self preferredUTIForExtention:fileExtension];
if (UTTypeConformsTo(CFBridgingRetain(fileUTI), kUTTypeImage)) {
NSLog(@"png file");
}
....
-(NSString *)preferredUTIForExtention:(NSString *)ext {
//Request the UTI via the file extension
NSString *theUTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)(ext), NULL);
return theUTI;
}
写作会让你往回看。既然你不能掌控人生,只是你可以掌控有自己叙述的版本。