Understanding Uniform Type Identifiers

Uniform Type Identifiers (UTIs) are used by the system to identify the type of files or in-memory data. For a file, the UTI is determined by the system with the help of its extension and its creator or its MIME type. As an example, Mac and iOS applications use UTIs to declare the format for data they place on a pasteboard. Mac apps use UTIs to declare the types of files that they are able to open.

Related Topics:

  • File Type Group Editor

  • Using File Type Groups

  • Webinar: All About File Types

Usage in Xojo

In Xojo, you specify UTIs for files using File Type Groups. The can then be used to select specific types of file or to control icons used with files owned by your apps.

The Clipboard class uses UTIs to identify its contents.

The SpotlightQuery class uses UTIs to search for specify files.

Inheritance

Uniform Type Identifiers support multiple inheritance, i.e. a UTI can be a child of any number of other UTIs. It is said to conform to another UTI. For example, the UTI for an AVI movie file is public.avi and it conforms to:

  • public.movie: the base type for any movie

  • public.audiovisual-content

  • public.data: the base type for physical files or data

  • public.item: the base type for the physical hierarchy

  • public.content: the base type for all document content

UTI System tips

Getting all the UTIs declared on a system

In the Terminal application (in Applications→Utilities→Terminal), type the following command (case-sensitive) to display a list of all UTIs declared by the system and other applications:

mdimport -A

Getting UTI and other metadata of a given file

In the Terminal application (in Applications→Utilities→Terminal), type the following command (case-sensitive):

mdls      (followed by a space)

then drag & drop the file you want information on onto the Terminal window and press the return key.

Among other metadata used by Spotlight, you should see the following for an AVI file:

kMDItemContentType             = "public.avi"
kMDItemContentTypeTree         = (
    "public.avi",
    "public.movie",
    "public.audiovisual-content",
    "public.data",
    "public.item",
    "public.content"
)
  • kMDItemContentType contains the file's UTI

  • kMDItemContentTypeTree is the list of all the UTIs the file conforms to.