Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UTI

 UTI

Presented at potatotips 19

Avatar for cockscomb

cockscomb

July 14, 2015
Tweet

More Decks by cockscomb

Other Decks in Programming

Transcript

  1. UTI

  2. File Types
 have many representations • Extension — .jpeg •

    MIME Type — image/jpeg • UTI — public.jpeg
  3. File Types
 have many representations • Extension • for file

    name • MIME Type • for Internet (Content-Type) • UTI?
  4. Uniform Type Identifier • Used inside iOS/OS X • Have

    inheritance • public.content/public.data → public.image → public.jpeg
  5. MIME Type → Extension func extensionFromMIMEType(MIMEType: String) -> String {

    let uti = UTTypeCreatePreferredIdentifierForTag( kUTTagClassMIMEType, MIMEType, nil ).takeRetainedValue() let ext = UTTypeCopyPreferredTagWithClass( uti, kUTTagClassFilenameExtension ).takeRetainedValue() return ext as String } extensionFromMIMEType("image/jpeg")
  6. MIME Type → Extension func extensionFromMIMEType(MIMEType: String) -> String {

    let uti = UTTypeCreatePreferredIdentifierForTag( kUTTagClassMIMEType, MIMEType, nil ).takeRetainedValue() let ext = UTTypeCopyPreferredTagWithClass( uti, kUTTagClassFilenameExtension ).takeRetainedValue() return ext as String } extensionFromMIMEType("image/jpeg")
  7. Create your file type <array> <dict> <key>CFBundleTypeIconFiles</key> <array/> <key>CFBundleTypeName</key> <string>Awesome

    File Format</string> <key>LSItemContentTypes</key> <array> <string>info.cockscomb.awesome</string> </array> </dict> </array>
  8. Uniform Type Identifier • Can convert to file extension and

    MIME Type • Can be simple to use with UTIKit ✌ • Can be defined your own one