deleteAllData
TypeScriptdeleteAllData(): voidSwift declarationfunc deleteAllData()class · iOS 17.0+ · SDK 27.1
class ModelContainerAn object that manages an app's schema and model storage configuration.
deleteAllData(): voidSwift declarationfunc deleteAllData()get mainContext(): Promise<ModelContext>Swift declaration@MainActor var mainContext: ModelContext { get }get configurations(): Array<ModelConfiguration>Swift declarationvar configurations: Set<ModelConfiguration> { get set }set configurations(value: Array<ModelConfiguration>)Swift declarationvar configurations: Set<ModelConfiguration> { get set }storeIdentifier(name: string): (string) | nullSwift declarationfunc storeIdentifier(forConfigurationNamed name: String) -> String?Returns the on-disk store identifier for the given configuration name. Store identifiers are stable strings derived from the backing file path or the store's own initialization — they are *not* the configuration name. Use this function when you have the name you passed to `ModelConfiguration` and need the corresponding identifier to filter a `HistoryDescriptor`, interpret `PersistentIdentifier.storeIdentifier`, or route to a specific store. If no `ModelConfiguration` was given an explicit name at initialization time, the default name is `"default"`. - Parameter name: The `name` value from the `ModelConfiguration` used to create the store. - Returns: The store identifier string, or `nil` if no store is associated with `name` or if `invalidate()` has been called on this container.
configurationName(identifier: string): (string) | nullSwift declarationfunc configurationName(forStoreIdentifier identifier: String) -> String?Returns the configuration name associated with the given on-disk store identifier. Use this when you already have a store identifier — such as `PersistentIdentifier.storeIdentifier` from a fetched object or a store identifier from a history transaction — and need to map it back to the human-readable configuration name that produced that store. - Parameter identifier: A store identifier string, for example from `PersistentIdentifier.storeIdentifier` or a history transaction's store identifier. - Returns: The `name` of the `ModelConfiguration` that backs the given store, or `nil` if no store with that identifier exists in this container or if `invalidate()` has been called.
static initForConfigurations(givenSchema: Schema, configurations: Array<ModelConfiguration>): ModelContainerSwift declarationinit(for givenSchema: Schema, migrationPlan: (any SchemaMigrationPlan.Type)? = nil, configurations: [ModelConfiguration]) throwsstatic initForConfigurations77162(givenSchema: Schema, configurations: Array<SDKHandle>): ModelContainerSwift declarationinit(for givenSchema: Schema, configurations: [any DataStoreConfiguration]) throwserase(): voidSwift declarationfunc erase() throwsget schema(): SchemaSwift declarationfinal let schema: Schema4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
ModelContainer.migrationPlan
Passing a Swift type itself is not supported.
ModelContainer.init(for:migrationPlan:configurations:)
Passing a Swift type itself is not supported.
ModelContainer.init(for:migrationPlan:configurations:)
A variable number of Swift arguments is not supported.
ModelContainer.init(for:configurations:)
Passing a Swift type itself is not supported.