Latest 1.0.6
Homepage https://github.com/mkeiser/SwiftUTI
License MIT
Platforms ios 8.0, osx 10.10
Authors

A swift wrapper around Apples Universal Type Identifier functions.

Usage

A typical usage might be like that:

let fileURL = URL(fileURLWithPath: ...)
let fileUTI = UTI(withExtension: fileURL.pathExtension)

// Check if it is a specific UTI (UTIs are equatable):

if fileUTI == UTI.pdf {

    // handle PDF document...
}

// Check if an UTI conforms to a UTI:

if fileUTI.conforms(to: .image) {

    // Handle image file...
}

Creating System and Custom UTIs

All system defined UTTypes are available as static variables. For example, to access the UTType for PDF documents, simply call UTI.pdf.

To define your own UTI (perhaps for your custom document type), you should make an extension like this:

public extension UTI {

    static let myDocument = UTI(rawValue: "com.mycompany.mydocument")
}

Your custom type is then accessible like this: UTI.myDocument.

Tags

You can easily create UTIs from any tag class, as well as access tags from an UTI instance. For example to get the MIME type of PDFs, simply call UTI.pdf.mimeType.

Latest podspec

{
    "name": "SwiftUTI",
    "version": "1.0.6",
    "summary": "A swift wrapper around Apples Universal Type Identifier functions.",
    "description": "This module makes it very simple to work with Apples Universal Type Identifiers.",
    "homepage": "https://github.com/mkeiser/SwiftUTI",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "mkeiser": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mkeiser/SwiftUTI.git",
        "tag": "1.0.6"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    },
    "source_files": "Sources/*",
    "osx": {
        "frameworks": "CoreServices"
    },
    "ios": {
        "frameworks": "MobileCoreServices"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This