Creates and populates a store with the external records found at a given URL.
SDK
- macOS 10.6+
Framework
- Core Data
Declaration
- (NSPersistent Store *)importStoreWithIdentifier:(NSString *)storeIdentifier fromExternalRecordsDirectory:(NSURL *)externalRecordsURL toURL:(NSURL *)destinationURL options:(NSDictionary *)options withType:(NSString *)storeType error:(NSError * _Nullable *)error;
Parameters
storeIdentifier
The identifier for a store.
If this value is
nil
then the method imports the records for the first store found.externalRecordsURL
The location of the directory containing external records.
destinationURL
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).
options
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.
storeType
A string constant (such as
NSSQLite
) that specifies the type of the new store—see Persistent Store Types.Store Type error
If an error occurs, upon return contains an instance of
NSError
that describes the problem.
Return Value
An object representing the newly-created store.
Discussion
Handling Errors in Swift:
In Swift, this method returns a nonoptional result and is marked with the throws
keyword to indicate that it throws an error in cases of failure.
You call this method in a try
expression and handle any errors in the catch
clauses of a do
statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.