Metadata Importer Reference

Framework
CoreServices/CoreServices.h
Declared in
MDImporter.h
Companion guides
Spotlight Overview
Spotlight Importer Programming Guide
Plug-in Programming Topics

Overview

An MDImporter is responsible for returning the metadata contained with a file. The Spotlight server is notified when a file is changed and loads the appropriate importer to extract the metadata. An importer is implemented as a CFPlugin.

Callbacks

ImporterImportData

Defines a pointer to an importer import callback that imports importers.

typedef Boolean (* ImporterImportData)
(
void *thisInterface,
CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFStringRef pathToFile
)

If you name your function GetMetadataForFile, you would declare it like this:

Boolean GetMetadataForFile
(
void *thisInterface,
CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFStringRef pathToFile
)

Parameters
thisInterface

The CFPlugin object that is called. This value is passed to the callback function.

attributes

A mutable dictionary that you should populate with the metadata key/value pairs. This dictionary is created and passed to the callback function.

contentTypeUTI

The content type of the file as a uniform type identifier. This value is passed to the callback function.

pathToFile

The full path to the file. This value is passed to the callback function.

Return Value

Your callback function should return true if the metadata was successfully returned, false if the metadata was not returned.

Constants

kMDImporterTypeID

Type ID of an importer plug-in.

#define kMDImporterTypeID  CFUUIDGetConstantUUIDWithBytes(kCFAllocatorDefault,
0x8B,
0x08,
0xC4,
0xBF,
0x41,
0x5 B,
0x11,
0xD8,
0xB3,
0xF9,
0x00,
0x03,
0x93,
0x67,
0x26,
0xFC);
Constants
kMDImporterTypeID

Only importers with this type ID are loaded.

Available in OS X v10.4 and later.

Declared in MDImporter.h.

Discussion

The string representation of this UUID is 8B08C4BF-415B-11D8-B3F9-0003936726FC.

kMDImporterInterfaceID

Interface required by a importer plug-in.

#define kMDImporterInterfaceID  CFUUIDGetConstantUUIDWithBytes(kCFAllocatorDefault,
0x6E,
0xBC,
0x27,
0xC4,
0x89,
0x9 C,
0x11,
0xD8,
0x84,
0xAE,
0x00,
0x03,
0x93,
0x67,
0x26,
0xFC);
Constants
kMDImporterInterfaceID

Importers must implement an interface corresponding to this UUID.

Available in OS X v10.4 and later.

Declared in MDImporter.h.

Discussion

The string representation of this UUID is 6EBC27C4-899C-11D8-84A3-0003936726FC.