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 the type of the list.

    Lists can be filtered and sorted with the same predicates as Results<T>.

    When added as a property on Object models, the property must be declared as let and cannot be dynamic.

    See more

    Declaration

    Swift

    public final class List<T: Object>: ListBase
  • Migration is the object passed into a user-defined MigrationBlock when updating the version of a Realm instance.

    This object provides access to the previous and current Schemas for this migration.

    See more

    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 relationships
    • List<T: Object> for to-many relationships

    Querying

    You can gets Results of an Object subclass via tha objects(_:) free function or the objects(_:) instance method on Realm.

    Relationships

    See our Cocoa guide for more details.

    See more

    Declaration

    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 more

    Declaration

    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 more

    Declaration

    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 (see init(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 autoreleasepool {} and ensure you have no other strong references to it.

    See more

    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 more

    Declaration

    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 more

    Declaration

    Swift

    public final class Schema: CustomStringConvertible