Classes
The following classes are available globally.
-
LinkingObjectsis an auto-updating container type. It represents a collection of objects that link to its parent object.LinkingObjectscan be queried with the same predicates asList<T>andResults<T>.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 final class LinkingObjects<T: Object>: LinkingObjectsBase
-
Listis the container type in Realm used to define to-many relationships.Like Swift’s
Arrays, Lists are parameterized on a singleObjectsubclass (T).Lists can be filtered and sorted with the same predicates as
Results<T>.When added as a property on
See moreObjectmodels, the property must be declared asletand cannot bedynamic.Declaration
Swift
public final class List<T: Object>: ListBase
-
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 final class Migration
-
Objectis a class used to define Realm model objects.In Realm you define your model classes by subclassing
Objectand adding properties to be persisted. You then instantiate and use your custom subclasses instead of using theObjectclass directly.class Dog: Object { dynamic var name: String = "" dynamic var adopted: Bool = false let siblings = List<Dog>() }Supported property types
String,NSStringIntInt8,Int16,Int32,Int64FloatDoubleBoolNSDateNSDataRealmOptional<T>for optional numeric propertiesObjectsubclasses, to model many-to-one relationshipsList<T: Object>, to model many-to-many relationships
String,NSString,NSDate,NSDataandObjectsubclass properties can be declared as optional.Int,Int8, Int16, Int32,Int64,Float,Double,Bool, andListproperties cannot. To store an optional number, useRealmOptional<Int>,RealmOptional<Float>,RealmOptional<Double>, orRealmOptional<Bool>instead, which wraps an optional numeric value.All property types except for
ListandRealmOptionalmust be declared asdynamic var.ListandRealmOptionalproperties must be declared as non-dynamicletproperties.Querying
You can retrieve all objects of a given type from a Realm by calling the
objects(_:)instance method.Relationships
See our Cocoa guide for more details.
See moreDeclaration
Swift
public class Object: RLMObjectBase
-
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 final class ObjectSchema: CustomStringConvertible
-
A
RealmOptionalinstance represents a optional value for types that can’t be directly declared asdynamicin Swift, such asInt,Float,Double, andBool.To change the underlying value stored by a
See moreRealmOptionalinstance, mutate the instance’svalueproperty.Declaration
Swift
public final class RealmOptional<T: RealmOptionalType>: RLMOptionalBase
-
Propertyinstances represent properties persisted to Realm in the context of an object schema.When using Realm,
Propertyinstances allow performing migrations and introspecting the database’s schema.These property instances map to columns in the core database.
See moreDeclaration
Swift
public final class Property: CustomStringConvertible
-
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 final class Realm
-
An iterator for a
See moreRealmCollectionTypeinstance.Declaration
Swift
public final class RLMGenerator<T: Object>: GeneratorType -
A type-erased
RealmCollectionType.Instances of
See moreRealmCollectionTypeforward operations to an opaque underlying collection having the sameElementtype.Declaration
Swift
public final class AnyRealmCollection<T: Object>: RealmCollectionType
-
Resultsis an auto-updating container type in Realm returned from object queries.Resultscan be queried with the same predicates asList<T>, 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 extra 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.
See moreResultscannot be directly instantiated.Declaration
Swift
public final class Results<T: Object>: ResultsBase
-
Schemainstances represent collections of model object schemas persisted to 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 final class Schema: CustomStringConvertible
View on GitHub
Install in Dash
Classes Reference