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