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
Object
subclass (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 moreObject
models, the property must be declared aslet
and cannot bedynamic
.Declaration
Swift
public final class List<T: Object>: ListBase
-
Migration
is the object passed into a user-definedMigrationBlock
when updating the version of aRealm
instance.This object provides access to the previous and current
See moreSchema
s for this migration.Declaration
Swift
public final class Migration
-
In Realm you define your model classes by subclassing
Object
and 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
Int
Float
Double
Bool
NSDate
NSData
Object
subclasses for to-one relationshipsList<T: Object>
for to-many relationships
Querying
You can gets
Results
of an Object subclass via thaobjects(_:)
free function or theobjects(_:)
instance method onRealm
.Relationships
See our Cocoa guide for more details.
See moreDeclaration
Swift
public class Object: RLMObjectBase
-
This class represents Realm model object schemas persisted to Realm in a Schema.
When using Realm, ObjectSchema objects 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
-
This class represents properties persisted to Realm in an ObjectSchema.
When using Realm, Property objects 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 (seeinit(inMemoryIdentifier:)
).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
See moreautoreleasepool {}
and ensure you have no other strong references to it.Declaration
Swift
public final class Realm
-
Results
is 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,
Schema
objects 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