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 NSObject
s. Unlike RLMRealm
s
and RLMObject
s, 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
fileURL
.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 to open the Realm in read-only mode.
This is required to be able to open Realm files which are not writeable or are in a directory which is not writeable. This should only be used on files which will not be modified by anyone while they are open, and not just to get a read-only view of a file which may be written to by another thread or process. Opening in read-only mode requires disabling Realm’s reader/writer coordination, so committing a write transaction from another process will result in crashes.
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 toYES
doesn’t disable file format migrations.Declaration
Objective‑C
@property (assign, readwrite, nonatomic) BOOL deleteRealmIfMigrationNeeded;
Swift
var deleteRealmIfMigrationNeeded: Bool { get set }
-
The classes managed by the Realm.
Declaration
Objective‑C
@property (readwrite, copy, nonatomic, nullable) NSArray *objectClasses;
Swift
var objectClasses: [AnyObject]? { get set }