RLMRealmConfiguration

@interface RLMRealmConfiguration : NSObject <NSCopying>

An RLMRealmConfiguration instance describes the different options used to create an instance of a Realm.

RLMRealmConfiguration instances are just plain NSObjects. Unlike RLMRealms and RLMObjects, they can be freely shared between threads as long as you do not mutate them.

Creating configuration objects 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 object for each distinct configuration rather than creating a new object each time you open a Realm.

  • Returns the default configuration used to create Realms when no other configuration is explicitly specified (i.e. +[RLMRealm defaultRealm]).

    Declaration

    Objective‑C

    + (nonnull instancetype)defaultConfiguration;

    Swift

    class func defaultConfiguration() -> Self

    Return Value

    The default Realm configuration.

  • Sets the default configuration to the given RLMRealmConfiguration.

    Declaration

    Objective‑C

    + (void)setDefaultConfiguration:(nonnull RLMRealmConfiguration *)configuration;

    Swift

    class func setDefaultConfiguration(configuration: RLMRealmConfiguration)

    Parameters

    configuration

    The new default Realm configuration.

  • The local URL of the Realm file. Mutually exclusive with inMemoryIdentifier.

    Declaration

    Objective‑C

    @property (readwrite, copy, nonatomic, nullable) NSURL *fileURL;

    Swift

    @NSCopying var fileURL: NSURL? { get set }
  • A string used to identify a particular in-memory Realm. Mutually exclusive with path.

    Declaration

    Objective‑C

    @property (readwrite, copy, nonatomic, nullable) NSString *inMemoryIdentifier;

    Swift

    var inMemoryIdentifier: String? { get set }
  • A 64-byte key to use to encrypt the data, or nil if encryption is not enabled.

    Declaration

    Objective‑C

    @property (readwrite, copy, nonatomic, nullable) NSData *encryptionKey;

    Swift

    @NSCopying var encryptionKey: NSData? { get set }
  • Whether the Realm is read-only (must be YES for read-only files).

    Declaration

    Objective‑C

    @property (assign, readwrite, nonatomic) BOOL readOnly;

    Swift

    var readOnly: Bool { get set }
  • The current schema version.

    Declaration

    Objective‑C

    @property (assign, readwrite, nonatomic) uint64_t schemaVersion;

    Swift

    var schemaVersion: UInt64 { get set }
  • The block which migrates the Realm to the current version.

    Declaration

    Objective‑C

    @property (readwrite, copy, nonatomic, nullable)
        RLMMigrationBlock migrationBlock;
  • 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 YES deletes the file if a migration would otherwise be required or executed.

    Note

    Setting this property to YES doesn’t disable file format migrations.

    Declaration

    Objective‑C

    @property (assign, readwrite, nonatomic) BOOL deleteRealmIfMigrationNeeded;

    Swift

    var deleteRealmIfMigrationNeeded: Bool { get set }
  • The classes persisted in the Realm.

    Declaration

    Objective‑C

    @property (readwrite, copy, nonatomic, nullable) NSArray *objectClasses;

    Swift

    var objectClasses: [AnyObject]? { get set }