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

UTI

 UTI

Presented at potatotips 19

58b40ae3b0db6cf0202a3802e9dd70fe?s=128

cockscomb

July 14, 2015
Tweet

Transcript

  1. UTI

  2. cockscomb

  3. None
  4. None
  5. gion-matsuri.jpg

  6. ion-matsuri.jpg

  7. JPEG

  8. JPEG image/jpeg .jpeg public.jpeg

  9. PNG image/png .png public.png

  10. PNG image/png .png public.png Extension MIME Type UTI

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

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

    name • MIME Type • for Internet (Content-Type) • UTI?
  13. Uniform Type Identifier

  14. Uniform Type Identifier • Used inside iOS/OS X • Have

    inheritance • public.content/public.data → public.image → public.jpeg
  15. let manager = PHImageManager.defaultManager() manager.requestImageDataForAsset(asset, options: options) { (data, dataUTI,

    orientation, info) in // Do something } Get image data from Photos
  16. let manager = PHImageManager.defaultManager() manager.requestImageDataForAsset(asset, options: options) { (data, dataUTI,

    orientation, info) in // Do something } Get image data from Photos
  17. UTI → Extension UTTypeCopyPreferredTagWithClass( "public.jpeg", kUTTagClassFilenameExtension ).takeRetainedValue() // jpeg

  18. MIME Type → UTI UTTypeCreatePreferredIdentifierForTag( kUTTagClassMIMEType, "image/jpeg", nil ).takeRetainedValue() //

    public.jpeg
  19. 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")
  20. cockscomb/UTIKit

  21. 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")
  22. MIME Type → Extension import UTIKit UTI(MIMEType: "image/jpeg").filenameExtension

  23. 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>
  24. Uniform Type Identifier • Can convert to file extension and

    MIME Type • Can be simple to use with UTIKit ✌ • Can be defined your own one
  25. ௖ ৴ ઩ ෹ ౭ http://hatenacorp.jp/recruit/