Documentation

ETUTI class documentation

ETUTI : NSObject <NSCopying>

A type class to represent data types and aggregate various type representations into a common type model (Uniform Type Identifier).

AuthorsGenerated by qmathe
Declared inETUTI.h

Overview

ETUTI objects represent Uniform Type Identifiers (UTIs), strings written in reverse-DNS notation (e.g. org.etoile.group) which are used to describe data type. UTIs support multiple inheritance to indicate that certain types are refinements of one or more parent types.

The ETUTI implementation also integrates with the Objective-C runtime. UTI's can be automatically generated for a given class, which are given the form org.etoile-project.objc.class.ClassName

EtoileFoundation provides a built-in UTI library and some class bindings (UTI supertypes to which ObjC classes conforms to). See UTIDefinitions.plist and ClassBindings.plist in the EtoileFoundation framework resources.

Additional UTIs and class bindings can be provided in third-party applications or frameworks. At launch time, ETUTI loads any UTIDefinitions.plist and ClassBindings.plist present in the main bundle and loaded frameworks, and merges the content into its runtime UTI database. You cannot redefine a UTI built into EtoileFoundation UTIDefinitions.plist.

iOS Support

EtoileFoundation UTIDefinitions.plist and UTIClassBindings.plist must be referenced by your application project, and bundled in the application with a Copy Files build phase where the subpath is a 'EtoileFoundation' subdirectory.

A Copy Bundle Resources phase can follow to copy the additional UTIDefinitions.plist and UTIClassBindings.plist specific to your application.


Initialization

+ (ETUTI *) typeWithString: (NSString *)aString

Returns an ETUTI object for the given UTI string (e.g. public.audio). The given UTI string must either:

  • be in the UTIDefinitions.plist file
  • or have been registered with the registertypeWithString:description:supertypes: method
  • or be a UTI of the form org.etoile-project.objc.class.ClassName where ClassName is a valid Objective-C class

Otherwise, nil is returned.

    + (ETUTI *) typeWithPath: (NSString *)aPath

    Returns an ETUTI object representing the type of the file located at the specified local path.

      + (ETUTI *) typeWithFileExtension: (NSString *)anExtension
      Description forthcoming.
        + (ETUTI *) typeWithMIMEType: (NSString *)aMIME
        Description forthcoming.
          + (ETUTI *) typeWithClass: (Class)aClass

          Returns an ETUTI object representing the given class. Calling -supertypes will return a UTI representing the superclass of the class, in addition to any supertypes specified for the class in UTIDefinitions.plist.

          Note that it is not necessary to list Objective-C classes in UTIDefinitons.plist; ETUTI objects for ObjC classes are created dynamically, but UTIDefinitions.plist can be used to add supplemental supertypes.

            + (ETUTI *) registerTypeWithString: (NSString *)aString description: (NSString *)description supertypeStrings: (NSArray *)supertypeNames typeTags: (NSDictionary *)tags

            Registers a UTI in the UTI database. UTIs registered with this method are not currently persisted.

            A type tag dictionary can be passed to express how the UTI is mapped to other type identification models. EUTI currently supports two other type identification models: file extensions and MIME types. All MIME types and file extensions belongs to two tag classes (encoded as UTI), respectively kETUTITagClassMIMEType and kETUTITagClassFileExtension. Finally each entry in a type tag dictionary must be an array. Here is an example of a valid type tag dictionary:

             [NSDictionary dictionaryWithObjectsAndKeys: 
             	[NSArray arrayWithObject: @"image/tiff"], kETUTITagClassMIMEType,
             	[NSArray arrayWithObjects: @"tif", @"tiff", nil], kETUTITagClassFileExtension, nil]
             

            See also -fileExtensions and -MIMETypes .

              + (void) registerTypesFromBundle: (NSBundle *)aBundle

              Registers additional UTIs and class bindings in the UTI database by loading any UTIDefinitions.plist and ClassBindings.plist present in the bundle resources directory.

              UTIs and class bindings registered with this method are not persisted.

                + (ETUTI *) transientTypeWithSupertypeStrings: (NSArray *)supertypeNames

                Returns a "transient" or anonymous ETUTI object based on the given UTI string representations as supertypes.

                Useful in combination with conformsToUTI: for checking whether an unknown UTI conforms to any UTI in a set (the supertypes specified for the transient UTI.)

                  + (ETUTI *) transientTypeWithSupertypes: (NSArray *)supertypes

                  Returns a "transient" or anonymous ETUTI object based on the given UTI objects as supertypes.

                  See also +transientTypeWithSupertypeStrings:

                    Type Representations and Informations

                    - (NSString *) stringValue

                    Returns the string representation of the UTI (e.g. public.audio).

                      - (Class) classValue

                      Returns the ObjC class the UTI represents, or Nil if the UTI does not represent a class registered in the runtime.

                      See also +typeWithClass: .

                        - (NSArray *) fileExtensions

                        Returns an array of file extensions (if any) which refer to the same data type as the receiver.

                          - (NSArray *) MIMETypes

                          Returns an array of MIME types which refer to the same data type as the receiver.

                            - (NSString *) typeDescription

                            Returns a natural language description of the receiver.

                              Type Inheritance

                              - (NSArray *) supertypes

                              Returns the UTI objects which are immediate supertypes of the receiver.

                                - (NSArray *) allSupertypes

                                Returns all known UTI objects which are supertypes of the receiver (all UTIs which the receiver conforms to).

                                The immediate supertypes comes first in the returned array.

                                Types higher in the hierarchy follow. The ordering among the supertypes beside the immediate supertypes is undetermined (due to multiple inheritance).

                                  - (NSArray *) subtypes

                                  Returns the UTI objects which have the receiver as an immediate supertype.

                                    - (NSArray *) allSubtypes

                                    Returns all known UTI objects which conform to the receiver.

                                      Type Conformance

                                      - (BOOL) conformsToType: (ETUTI *)aType

                                      Tests whether or not the receiver conforms to aType (i.e. aType is a supertype of the receiver, possibly many levels away).