AdAvAn / Cutis

A thin Swift wrapper around the UTI APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cutis

CocoaPods Carthage compatible

Cutis ("Comfortable UTIs") is a thin Swift wrapper on top of the UTI (Uniform Type Identifier) C API.

Apart from providing a typesafe and object-oriented wrapper around type identifiers, Cutis does the heavy lifting for you by taking care of the casting and memory management required when interacting with CoreFoundation-style APIs.

If you deal a lot with type identifiers in your project, Cutis can make your code simpler and easier to follow.

Examples

Getting the default file extension for a type:

let uti = UTType("com.adobe.pdf")

if let tags = uti.declaration?.tagSpecification,
   let allExts = tags[UTTypeTagClass.FileExtension],
   let ext = allExts.first {
    NSLog("preferred file extension for the given type: %@", ext)
}

Checking whether there is an image representation of a given pasteboard item:

func hasImageRep(item: NSPasteboardItem) -> Bool {
   return item.types.contains({ UTType($0).conformsTo(.Image) })
}

Requirements

Xcode 7, Swift 2.1, OSX 10.9, iOS 8.0

About

A thin Swift wrapper around the UTI APIs

License:MIT License


Languages

Language:Swift 97.3%Language:Ruby 1.5%Language:Objective-C 1.1%