What should I do with UTI (NSImage.imageTypes)?

Per the docs, NSImage.imageTypes returns a list UTI's, something like below:

com.adobe.pdf
com.apple.pict
com.adobe.encapsulated-postscript
public.jpeg
public.png
com.compuserve.gif
com.canon.tif-raw-image
...

What I need is get file extensions of a UTI. For example, public.jpeg picture file may have several file extensions, say .jpg,.jpeg,.jfif.

Does Cocoa provide any API to query for this information?

Accepted Reply

Let me introduce you to the Uniform Type Identifiers framework.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Replies

Let me introduce you to the Uniform Type Identifiers framework.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes! That's just what I need.

if let ut = UTType.types(tag: "jpeg", tagClass: .filenameExtension, conformingTo: nil).first {
    print(ut.tags[.filenameExtension])
}