Created
March 3, 2019 10:38
-
-
Save laevandus/25358bd14c075622b86e5d2d48d7f607 to your computer and use it in GitHub Desktop.
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 MobileCoreServices | |
struct UTI { | |
let identifier: String | |
init(identifier: CFString) { | |
self.identifier = identifier as String | |
} | |
init(tagClass: CFString, tag: String) { | |
let preferred = UTTypeCreatePreferredIdentifierForTag(tagClass, tag as CFString, nil) | |
identifier = preferred!.takeRetainedValue() as String | |
} | |
func conforms(to uti: UTI) -> Bool { | |
return UTTypeConformsTo(identifier as CFString, uti.identifier as CFString) | |
} | |
static let pdf = UTI(identifier: kUTTypePDF) | |
static let text = UTI(identifier: kUTTypeText) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment