KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: UTI specifies file types on Mac OS X
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac OS X
Published On: October 1, 2008

Uniform Type Identifiers (UTI) were developed by Apple as a replacement for OSType in Mac OS X. A Uniform Type Identifier is a string that provides a consistent identifier for a data file type on Mac OS X, and can replace the equivalent TYPE, MIME type, or filename extension. For a JPEG image file for example, instead of trying to decide between "JPEG", ".jpg", ".jpeg", "image/jpeg", etc., the UTI type would always be public.jpeg.

The format for UTI is the reverse-DNS format commonly used for Java class packages and MacOS X bundles. The public domain is a hierarchy containing many common types, such as public.data (the superclass of the hierarchy), public.text, public.html (subclass of text), public.image, public.jpeg (subclass of image).

An example of a 4D command that can take advantage of UTI is "Select document", as in the following code:

$defaultDir:=""
$filter:="public.image"
$title:="File Picker"
$option:=Multiple files

Fieldname1:=Select document($defaultDir;$filter;$title;$option)


The "Select document" command opens a file picker dialog window. The UTI public.image in the command's file type filter would allow the user to pick any file in the public.image sub-hierarchy, including public.jpeg, public.tiff, etc. All UTI types not in that sub-hierarchy, such as various text file types, would be dimmed out and not selectable in the file picker dialog.