Instance Method


Creates and populates a store with the external records found at a given URL.


func importStore(withIdentifier storeIdentifier: String?, fromExternalRecordsDirectoryAt externalRecordsURL: URL, to destinationURL: URL, options: [AnyHashable : Any]? = nil, ofType storeType: String) throws -> NSPersistentStore



The identifier for a store.

If this value is nil then the method imports the records for the first store found.


The location of the directory containing external records.


An URL object that specifies the location for the new store.

There should be no existing store at this location, as the store will be created from scratch (appending to an existing store is not allowed).


A dictionary containing key-value pairs that specify whether the store should be read-only, and whether (for an XML store) the XML file should be validated against the DTD before it is read. For key definitions, see Store Options.


A string constant (such as NSSQLiteStoreType) that specifies the type of the new store—see Persistent Store Types.


If an error occurs, upon return contains an instance of NSError that describes the problem.

Return Value

An object representing the newly-created store.


See Also

Working with Spotlight

class NSCoreDataCoreSpotlightDelegate

A delegate that supports Core Spotlight integration.

class func elementsDerived(fromExternalRecordAt: URL) -> [AnyHashable : Any]

Returns a dictionary containing the parsed elements derived from the Spotlight external record file that is specified by the given URL.

Spotlight External Record Elements

Specify values for the parsed elements derived from the Spotlight external record file.