Created
March 23, 2019 21:15
-
-
Save kylehowells/c6286d77bc4b0462fe46e8fa4ba7bb88 to your computer and use it in GitHub Desktop.
Print the preferred UTI Document Type for a file extension, then print all possible matching UTI's and their definitions to debug problems.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import CoreServices; | |
// All Bundle Ids | |
NSString *pathExtension = @"db"; | |
NSLog(@"pathExtension: %@", pathExtension); | |
CFStringRef preferedUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)pathExtension, NULL); | |
NSLog(@"%@ - Preferred UTI: %@", pathExtension, preferedUTI); | |
CFDictionaryRef defintion = UTTypeCopyDeclaration(preferedUTI); | |
NSLog(@"defintion: %@", defintion); | |
CFArrayRef utisRef = UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)pathExtension, nil); | |
NSLog(@"UTI: utisRef %@", utisRef); | |
NSArray *utis = CFBridgingRelease(utisRef); | |
for (NSString *uti in utis) { | |
CFDictionaryRef defintion = UTTypeCopyDeclaration((__bridge CFStringRef)uti); | |
NSDictionary *dict = CFBridgingRelease(defintion); | |
NSLog(@"defintion: %@", dict); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment