Configuration
public struct Configuration
A Configuration instance describes the different options used to
create an instance of a Realm.
Configuration instances are just plain Swift structs. Unlike Realms
and Objects, they can be freely shared between threads as long as you do not
mutate them.
Creating configuration values for class subsets (by setting the
objectClasses property) can be expensive. Because of this, you will normally want to
cache and reuse a single configuration value for each distinct configuration rather than
creating a new value each time you open a Realm.
-
Returns the default configuration used to create Realms when no other configuration is explicitly specified (i.e.
Realm()).Declaration
Swift
public static var defaultConfiguration: Configuration
-
init(fileURL:inMemoryIdentifier:encryptionKey:readOnly:schemaVersion:migrationBlock:deleteRealmIfMigrationNeeded:objectTypes:)Initializes a
Realm.Configuration, suitable for creating newRealminstances.Declaration
Swift
public init(fileURL: NSURL? = NSURL(fileURLWithPath: RLMRealmPathForFile("default.realm"), isDirectory: false), inMemoryIdentifier: String? = nil, encryptionKey: NSData? = nil, readOnly: Bool = false, schemaVersion: UInt64 = 0, migrationBlock: MigrationBlock? = nil, deleteRealmIfMigrationNeeded: Bool = false, objectTypes: [Object.Type]? = nil)Parameters
fileURLThe local URL to the Realm file.
inMemoryIdentifierA string used to identify a particular in-memory Realm.
encryptionKeyAn optional 64-byte key to use to encrypt the data.
readOnlyWhether the Realm is read-only (must be true for read-only files).
schemaVersionThe current schema version.
migrationBlockThe block which migrates the Realm to the current version.
deleteRealmIfMigrationNeededIf
true, recreate the Realm file with the provided schema if a migration is required.objectTypesThe subset of
Objectsubclasses persisted in the Realm.
-
The local URL of the Realm file. Mutually exclusive with
inMemoryIdentifier.Declaration
Swift
public var fileURL: NSURL? -
A string used to identify a particular in-memory Realm. Mutually exclusive with
path.Declaration
Swift
public var inMemoryIdentifier: String? -
A 64-byte key to use to encrypt the data, or
nilif encryption is not enabled.Declaration
Swift
public var encryptionKey: NSData? = nil -
Whether the Realm is read-only (must be
truefor read-only files).Declaration
Swift
public var readOnly: Bool = false -
The current schema version.
Declaration
Swift
public var schemaVersion: UInt64 = 0 -
The block which migrates the Realm to the current version.
Declaration
Swift
public var migrationBlock: MigrationBlock? = nil -
Whether to recreate the Realm file with the provided schema if a migration is required. This is the case when the stored schema differs from the provided schema or the stored schema version differs from the version on this configuration. Setting this property to
truedeletes the file if a migration would otherwise be required or executed.Note
Setting this property totruedoesn’t disable file format migrations.Declaration
Swift
public var deleteRealmIfMigrationNeeded: Bool = false -
The classes persisted in the Realm.
Declaration
Swift
public var objectTypes: [Object.Type]?
View on GitHub
Install in Dash
Configuration Struct Reference