Slide 1

Slide 1 text

UTI

Slide 2

Slide 2 text

cockscomb

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

gion-matsuri.jpg

Slide 6

Slide 6 text

ion-matsuri.jpg

Slide 7

Slide 7 text

JPEG

Slide 8

Slide 8 text

JPEG image/jpeg .jpeg public.jpeg

Slide 9

Slide 9 text

PNG image/png .png public.png

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

File Types
 have many representations • Extension • for file name • MIME Type • for Internet (Content-Type) • UTI?

Slide 13

Slide 13 text

Uniform Type Identifier

Slide 14

Slide 14 text

Uniform Type Identifier • Used inside iOS/OS X • Have inheritance • public.content/public.data → public.image → public.jpeg

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

UTI → Extension UTTypeCopyPreferredTagWithClass( "public.jpeg", kUTTagClassFilenameExtension ).takeRetainedValue() // jpeg

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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")

Slide 20

Slide 20 text

cockscomb/UTIKit

Slide 21

Slide 21 text

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")

Slide 22

Slide 22 text

MIME Type → Extension import UTIKit UTI(MIMEType: "image/jpeg").filenameExtension

Slide 23

Slide 23 text

Create your file type CFBundleTypeIconFiles CFBundleTypeName Awesome File Format LSItemContentTypes info.cockscomb.awesome

Slide 24

Slide 24 text

Uniform Type Identifier • Can convert to file extension and MIME Type • Can be simple to use with UTIKit ✌ • Can be defined your own one

Slide 25

Slide 25 text

௖ ৴ ઩ ෹ ౭ http://hatenacorp.jp/recruit/