UTIKit is an UTI (Uniform Type Identifier) wrapper for Swift.
UTIKit is a full featured library including entire UTI functions.
- Convertibility
- Filename extension
- MIME type
- OSType (OS X only)
- Pasteboard type (OS X only)
- Equality
- Conformance
- and others…
let jpeg = UTI("public.jpeg")
let jpeg = UTI(filenameExtension: "jpeg")
let jpeg = UTI(mimeType: "image/jpeg")
UTI(mimeType: "image/jpeg").filenameExtensions // => ["jpeg", "jpg", "jpe"]
UTI(filenameExtension: "jpeg").mimeTypes // => ["image/jpeg"]
UTI(mimeType: "image/jpeg") == UTI(filenameExtension: "jpeg") // => true
switch UTI(kUTTypeJPEG) {
case UTI(kUTTypeImage):
print("JPEG is a kind of images")
default:
fatalError("JPEG must be a image")
}
- Swift 5.0 or later
- iOS 8 or later
- OS X 10.10 or later
Hiroki Kato, [email protected]
UTIKit is available under the MIT license. See the LICENSE file for more info.