Structures
The following structures are available globally.
-
A
Realminstance (also referred to asa Realm
) represents a Realm database.Realms can either be stored on disk (see
init(path:)) or in memory (seeConfiguration).Realminstances are cached internally, and constructing equivalentRealmobjects (for example, by using the same path or identifier) produces limited overhead.If you specifically want to ensure a
Realminstance is destroyed (for example, if you wish to open a Realm, check some property, and then possibly delete the Realm file and re-open it), place the code which uses the Realm within anautoreleasepool {}and ensure you have no other strong references to it.See moreWarning
Realminstances are not thread safe and cannot be shared across threads or dispatch queues. You must construct a new instance for each thread in which a Realm will be accessed. For dispatch queues, this means that you must construct a new instance in each block which is dispatched, as a queue is not guaranteed to run all of its blocks on the same thread.Declaration
Swift
public struct Realm
-
LinkingObjectsis an auto-updating container type. It represents zero or more objects that are linked to its owning model object through a property relationship.LinkingObjectscan be queried with the same predicates asList<Element>andResults<Element>.LinkingObjectsalways reflects the current state of the Realm on the current thread, including during write transactions on the current thread. The one exception to this is when usingfor...inenumeration, which will always enumerate over the linking objects that were present when the enumeration is begun, even if some of them are deleted or modified to no longer link to the target object during the enumeration.
See moreLinkingObjectscan only be used as a property onObjectmodels. Properties of this type must be declared asletand cannot bedynamic.Declaration
Swift
public struct LinkingObjects<Element> where Element : Object
-
Migrationinstances encapsulate information intended to facilitate a schema migration.A
See moreMigrationinstance is passed into a user-definedMigrationBlockblock when updating the version of a Realm. This instance provides access to the old and new database schemas, the objects in the Realm, and provides functionality for modifying the Realm during the migration.Declaration
Swift
public struct Migration
-
Declaration
Swift
public struct PropertyChange
-
This class represents Realm model object schemas.
When using Realm,
ObjectSchemainstances allow performing migrations and introspecting the database’s schema.Object schemas map to tables in the core database.
See moreDeclaration
Swift
public struct ObjectSchema : CustomStringConvertible
-
Propertyinstances represent properties managed by a Realm in the context of an object schema. Such properties may be persisted to a Realm file or computed from other data in the Realm.When using Realm, property instances allow performing migrations and introspecting the database’s schema.
Property instances map to columns in the core database.
See moreDeclaration
Swift
public struct Property : CustomStringConvertible
-
An iterator for a
See moreRealmCollectioninstance.Declaration
Swift
public struct RLMIterator<Element> : IteratorProtocol where Element : RealmCollectionValue -
A type-erased
RealmCollection.Instances of
See moreRealmCollectionforward operations to an opaque underlying collection having the sameElementtype.Declaration
Swift
public struct AnyRealmCollection<Element> : RealmCollection where Element : RealmCollectionValue
-
Resultsis an auto-updating container type in Realm returned from object queries.Resultscan be queried with the same predicates asList<Element>, and you can chain queries to further filter query results.Resultsalways reflect the current state of the Realm on the current thread, including during write transactions on the current thread. The one exception to this is when usingfor...inenumeration, which will always enumerate over the objects which matched the query when the enumeration is begun, even if some of them are deleted or modified to be excluded by the filter during the enumeration.Resultsare lazily evaluated the first time they are accessed; they only run queries when the result of the query is requested. This means that chaining several temporaryResultsto sort and filter your data does not perform any unnecessary work processing the intermediate state.Once the results have been evaluated or a notification block has been added, the results are eagerly kept up-to-date, with the work done to keep them up-to-date done on a background thread whenever possible.
Results instances cannot be directly instantiated.
See moreDeclaration
Swift
public struct Results<Element> : Equatable where Element : RealmCollectionValue
-
Schemainstances represent collections of model object schemas managed by a Realm.When using Realm,
Schemainstances allow performing migrations and introspecting the database’s schema.Schemas map to collections of tables in the core database.
See moreDeclaration
Swift
public struct Schema : CustomStringConvertible
-
A
See moreSortDescriptorstores a key path and a sort order for use withsorted(sortDescriptors:). It is similar toNSSortDescriptor, but supports only the subset of functionality which can be efficiently run by Realm’s query engine.Declaration
Swift
public struct SortDescriptor
-
A
See moreSyncConfigurationrepresents configuration parameters for Realms intended to sync with a Realm Object Server.Declaration
Swift
public struct SyncConfiguration -
A
See moreSyncCredentialsrepresents data that uniquely identifies a Realm Object Server user.Declaration
Swift
public struct SyncCredentials
-
SyncSubscriptionrepresents a subscription to a set of objects in a synced Realm.When partial sync is enabled for a synced Realm, the only objects that the server synchronizes to the client are those that match a sync subscription registered by that client. A subscription consists of of a query (represented by a
Results) and an optional name.Changes to the state of the subscription can be observed using
SyncSubscription.observe(_:options:_:).Subscriptions are created using
See moreResults.subscribe()orResults.subscribe(named:).Declaration
Swift
public struct SyncSubscription : RealmCollectionValue
-
A description of the actual privileges which apply to a Realm.
This is a combination of all of the privileges granted to all of the Roles which the current User is a member of, obtained by calling
realm.getPrivileges().By default, all operations are permitted, and each privilege field indicates an operation which may be forbidden.
See moreDeclaration
Swift
public struct RealmPrivileges : OptionSet, CustomDebugStringConvertible -
A description of the actual privileges which apply to a Class within a Realm.
This is a combination of all of the privileges granted to all of the Roles which the current User is a member of, obtained by calling
realm.getPrivileges(ObjectClass.self)orrealm.getPrivileges(forClassNamed: "className")By default, all operations are permitted, and each privilege field indicates an operation which may be forbidden.
See moreDeclaration
Swift
public struct ClassPrivileges : OptionSet, CustomDebugStringConvertible -
A description of the actual privileges which apply to a specific Object.
This is a combination of all of the privileges granted to all of the Roles which the current User is a member of, obtained by calling
realm.getPrivileges(object).By default, all operations are permitted, and each privilege field indicates an operation which may be forbidden.
See moreDeclaration
Swift
public struct ObjectPrivileges : OptionSet, CustomDebugStringConvertible
-
An object intended to be passed between threads containing a thread-safe reference to its thread-confined object.
To resolve a thread-safe reference on a target Realm on a different thread, pass to
Realm.resolve(_:).Warning
A
ThreadSafeReferenceobject must be resolved at most once. Failing to resolve aThreadSafeReferencewill result in the source version of the Realm being pinned until the reference is deallocated.Note
Prefer short-lived
ThreadSafeReferences as the data for the version of the source Realm will be retained until all references have been resolved or deallocated.See moreSee
Declaration
Swift
public struct ThreadSafeReference<Confined> where Confined : ThreadConfined
View on GitHub
Install in Dash
Structures Reference