Classes
The following classes are available globally.
-
List<T>is the container type in Realm used to define to-many relationships.Lists hold a single
Objectsubclass (T) which defines thetype
of the List.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
-
Migrationis the object passed into a user-definedMigrationBlockwhen updating the version of aRealminstance.This object provides access to the previous and current
See moreSchemas for this migration.Declaration
Swift
public final class Migration
-
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 the Object class 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 for to-one relationshipsList<T: Object>for to-many relationships
String,NSString,NSDate,NSDataandObjectsubclass properties can be optional.Int,Int8, Int16, Int32,Int64,Float,Double,BoolandListproperties cannot. To store an optional number, instead useRealmOptional<Int>,RealmOptional<Float>,RealmOptional<Double>, orRealmOptional<Bool>instead, which wraps an optional value of the generic type.All property types except for
ListandRealmOptionalmust be declared asdynamic var.ListandRealmOptionalproperties must be declared as non-dynamicletproperties.Querying
You can gets
Resultsof an Object subclass via theobjects(_:)instance method onRealm.Relationships
See our Cocoa guide for more details.
See moreDeclaration
Swift
public class Object: RLMObjectBase
-
A
RealmOptionalrepresents a optional value for types that can’t be directly declared asdynamicin Swift, such asInts,Float,Double, andBool.It encapsulates a value in its
See morevalueproperty, which is the only way to mutate aRealmOptionalproperty on anObject.Declaration
Swift
public final class RealmOptional<T: RealmOptionalType>: RLMOptionalBase
-
This class represents properties persisted to Realm in an
ObjectSchema.When using Realm,
Propertyobjects allow performing migrations and introspecting the database’s schema.These properties map to columns in the core database.
See moreDeclaration
Swift
public final class Property: CustomStringConvertible
-
A Realm instance (also referred to as
a realm
) represents a Realm database.Realms can either be stored on disk (see
init(path:)) or in memory (seeConfiguration).Realm instances are cached internally, and constructing equivalent Realm objects (with the same path or identifier) produces limited overhead.
If you specifically want to ensure a Realm object 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 an
autoreleasepool {}and ensure you have no other strong references to it.See moreWarning
Realm instances are not thread safe and can not be shared across threads or dispatch queues. You must construct a new instance on each thread you want to interact with the realm on. For dispatch queues, this means that you must call it in each block which is dispatched, as a queue is not guaranteed to run on a consistent thread.Declaration
Swift
public final class Realm
-
Encapsulates iteration state and interface for iteration over a
See moreRealmCollectionType.Declaration
Swift
public final class RLMGenerator<T: Object>: GeneratorType -
A type-erased
RealmCollectionType.Forwards operations to an arbitrary underlying collection having the same Element type, hiding the specifics of the underlying
See moreRealmCollectionType.Declaration
Swift
public final class AnyRealmCollection<T: Object>: RealmCollectionType
-
Resultsis an auto-updating container type in Realm returned from object queries.Results can be queried with the same predicates as
List<T>and you can chain queries to further filter query results.Results cannot be created directly.
See moreDeclaration
Swift
public final class Results<T: Object>: ResultsBase
-
This class represents the collection of model object schemas persisted to Realm.
When using Realm,
Schemaobjects allow performing migrations and introspecting the database’s schema.
See moreSchemas map to collections of tables in the core database.Declaration
Swift
public final class Schema: CustomStringConvertible
View on GitHub
Install in Dash
Classes Reference