获取ALAsset的MIME类型

时间:2014-03-12 12:29:04

标签: ios mime-types alasset

有没有办法获取ALAsset的MIME类型?有一个很好的元数据方法:

NSDictionary *data = [[asset defaultRepresentation] metadata];

但这并不包含MIME类型数据......

1 个答案:

答案 0 :(得分:15)

ALAssetRepresentation *rep = [asset defaultRepresentation];

NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass
             ((__bridge CFStringRef)[rep UTI], kUTTagClassMIMEType);

这将为您提供MIME类型。您需要添加MobileCoreService框架并导入<MobileCoreServices/MobileCoreServices.h>