Moving from UTI to Extension or MIME Type
To go the other way, producing a preferred extension or MIME types from a UTI, use UTTypeCopyPreferredTagWithClass()
. The following functions return jpeg
and image/jpeg
, respectively, when passed public.jpeg
:
NSString *extensionForUTI(NSString *aUTI) { CFStringRef theUTI = (__bridge CFStringRef) aUTI; CFStringRef results = UTTypeCopyPreferredTagWithClass( theUTI, kUTTagClassFilenameExtension); return (__bridge_transfer NSString *)results; } NSString *mimeTypeForUTI(NSString *aUTI) { CFStringRef theUTI = (__bridge CFStringRef) aUTI; CFStringRef results = UTTypeCopyPreferredTagWithClass( theUTI, kUTTagClassMIMEType); ...
Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.