One Logo Pool Ball
_CoreSpotlight_FoundationModels · IOS API REFERENCE

FileSource

struct · iOS 27.0+ · SDK 27.1

struct FileSource

A search source that retrieves indexed metadata from files and directories visible to Spotlight. Use this type to search the metadata of your app’s custom file types. Configure the source with one or more directories for the tool to search. During a query, the Spotlight considers only the previously indexed files in those directories. When it finds a match, the tool delivers the item and any attributes you specify in the ``fetchAttributes`` property to the model for consideration. For more information about indexing your app’s files, see ``CSImportExtension``.

Members (7)

init · iOS 27.0+

init

TypeScript
static init(fetchAttributes?: Array<_CoreSpotlight_SearchableItemAttribute>): FileSource
Swift declaration
init(fetchAttributes: [SearchableItemAttribute] = [])
get · iOS 27.0+

fetchAttributes

TypeScript
get fetchAttributes(): Array<_CoreSpotlight_SearchableItemAttribute>
Swift declaration
var fetchAttributes: [SearchableItemAttribute]

The attributes to fetch for each file or directory and provide to the model. Use this property to minimize the number of round trips between the Spotlight search tool and your content. When you index your app’s content, you create a ``CSSearchableItemAttributeSet`` for each item and fill it with metadata about that item. For example, you might specify the title of a document and the number of pages it contains. For each item the Spotlight search tool identifies as a result, the tool retrieves the attributes you specify in this property. The tool delivers these attributes together with the item’s identifier to the model so it doesn’t have to request them later. The default value of this property is an empty set, which delivers only the item’s identifier to the model.

set · iOS 27.0+

fetchAttributes

TypeScript
set fetchAttributes(value: Array<_CoreSpotlight_SearchableItemAttribute>)
Swift declaration
var fetchAttributes: [SearchableItemAttribute]

The attributes to fetch for each file or directory and provide to the model. Use this property to minimize the number of round trips between the Spotlight search tool and your content. When you index your app’s content, you create a ``CSSearchableItemAttributeSet`` for each item and fill it with metadata about that item. For example, you might specify the title of a document and the number of pages it contains. For each item the Spotlight search tool identifies as a result, the tool retrieves the attributes you specify in this property. The tool delivers these attributes together with the item’s identifier to the model so it doesn’t have to request them later. The default value of this property is an empty set, which delivers only the item’s identifier to the model.

get · iOS 27.0+

maximumResultCount

TypeScript
get maximumResultCount(): (number) | null
Swift declaration
var maximumResultCount: Int?

The maximum number of results to retrieve from this source. Use this property to limit the number of results the Spotlight search tool returns to the model. If you specify `nil`, the tool returns all results that match the model’s query. This maximum applies only to the current source, and doesn’t include results from other sources, which have their own maximum values. The default value of this property is `nil`.

set · iOS 27.0+

maximumResultCount

TypeScript
set maximumResultCount(value: (number) | null)
Swift declaration
var maximumResultCount: Int?

The maximum number of results to retrieve from this source. Use this property to limit the number of results the Spotlight search tool returns to the model. If you specify `nil`, the tool returns all results that match the model’s query. This maximum applies only to the current source, and doesn’t include results from other sources, which have their own maximum values. The default value of this property is `nil`.

get · iOS 27.0+

scopes

TypeScript
get scopes(): Array<string>
Swift declaration
var scopes: [URL]

The directories to search. Specify one or more directory URLs to scope the search to those directories and their subdirectories. The default value of this property is an empty array, which searches all indexed volumes.

set · iOS 27.0+

scopes

TypeScript
set scopes(value: Array<string>)
Swift declaration
var scopes: [URL]

The directories to search. Specify one or more directory URLs to scope the search to those directories and their subdirectories. The default value of this property is an empty array, which searches all indexed volumes.

Skipped declarations

No declarations were skipped in this snapshot.

All _CoreSpotlight_FoundationModels types →