涉及的核心知识点

参考大神文章

传送门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;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-11-29
  • 2021-10-13
  • 2021-06-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
  • 2022-02-21
  • 2021-09-27
相关资源
相似解决方案