Classes
The following classes are available globally.
-
A 128-bit IEEE 754-2008 decimal floating point number.
This type is similar to Swift’s built-in Decimal type, but allocates bits differently, resulting in a different representable range. (NS)Decimal stores a significand of up to 38 digits long and an exponent from -128 to 127, while this type stores up to 34 digits of significand and an exponent from -6143 to 6144.
See moreDeclaration
Swift
@objc(RealmSwiftDecimal128) public final class Decimal128 : RLMDecimal128, Decodable
extension Decimal128: BSON
extension Decimal128: Encodable
extension Decimal128: ExpressibleByIntegerLiteral
extension Decimal128: ExpressibleByFloatLiteral
extension Decimal128: ExpressibleByStringLiteral
extension Decimal128: Comparable
extension Decimal128: RealmCollectionValue
extension Decimal128: MinMaxType
extension Decimal128: AddableType
-
A 12-byte (probably) unique object identifier.
ObjectIds are similar to a GUID or a UUID, and can be used to uniquely identify objects without a centralized ID generator. An ObjectID consists of:
- A 4 byte timestamp measuring the creation time of the ObjectId in seconds since the Unix epoch.
- A 5 byte random value
- A 3 byte counter, initialized to a random value.
ObjectIds are intended to be fast to generate. Sorting by an ObjectId field will typically result in the objects being sorted in creation order.
See moreDeclaration
Swift
@objc(RealmSwiftObjectId) public final class ObjectId : RLMObjectId, Decodable
extension ObjectId: BSON
extension ObjectId: Encodable
extension ObjectId: Comparable
extension ObjectId: RealmCollectionValue
-
List
is the container type in Realm used to define to-many relationships.Like Swift’s
Array
,List
is a generic type that is parameterized on the type it stores. This can be either anObject
subclass or one of the following types:Bool
,Int
,Int8
,Int16
,Int32
,Int64
,Float
,Double
,String
,Data
,Date
,Decimal128
, andObjectId
(and their optional versions)Unlike Swift’s native collections,
List
s are reference types, and are only immutable if the Realm that manages them is opened as read-only.Lists can be filtered and sorted with the same predicates as
Results<Element>
.Properties of
See moreList
type defined onObject
subclasses must be declared aslet
and cannot bedynamic
.Declaration
Swift
public final class List<Element> : RLMSwiftCollectionBase where Element : RealmCollectionValue
extension List: ObservableObject, RealmSubscribable
extension List: RealmCollection
extension List: MutableCollection
extension List: Decodable where Element: Decodable
extension List: Encodable where Element: Encodable
-
MutableSet
is the container type in Realm used to define to-many relationships with distinct values as objects.Like Swift’s
Set
,MutableSet
is a generic type that is parameterized on the type it stores. This can be either anObject
subclass or one of the following types:Bool
,Int
,Int8
,Int16
,Int32
,Int64
,Float
,Double
,String
,Data
,Date
,Decimal128
, andObjectId
(and their optional versions)Unlike Swift’s native collections,
MutableSet
s are reference types, and are only immutable if the Realm that manages them is opened as read-only.MutableSet’s can be filtered and sorted with the same predicates as
Results<Element>
.Properties of
See moreMutableSet
type defined onObject
subclasses must be declared aslet
and cannot bedynamic
.Declaration
Swift
public final class MutableSet<Element> : RLMSwiftCollectionBase where Element : RealmCollectionValue
extension MutableSet: ObservableObject, RealmSubscribable
extension MutableSet: RealmCollection
extension MutableSet: Decodable where Element: Decodable
extension MutableSet: Encodable where Element: Encodable
-
Map is a key-value storage container used to store supported Realm types.
Map is a generic type that is parameterized on the type it stores. This can be either an Object subclass or one of the following types: Bool, Int, Int8, Int16, Int32, Int64, Float, Double, String, Data, Date, Decimal128, and ObjectId (and their optional versions)
Note
Optional versions of the above types exceptObject
are only supported in non-synchronized Realms.Map only supports String as a key.
Unlike Swift’s native collections,
Map
s is a reference types, and are only immutable if the Realm that manages them is opened as read-only.A Map can be filtered and sorted with the same predicates as
Results<Value>
.Properties of
See moreMap
type defined onObject
subclasses must be declared aslet
and cannot bedynamic
.Declaration
Swift
public final class Map<Key, Value> : RLMSwiftCollectionBase where Key : _MapKey, Value : RealmCollectionValue
extension Map: ObservableObject, RealmSubscribable
extension Map: Sequence
extension Map: RealmKeyedCollection
extension Map: Decodable where Key: Decodable, Value: Decodable
extension Map: Encodable where Key: Encodable, Value: Encodable
-
A
RealmOptional
instance represents an optional value for types that can’t be directly declared as@objc
in Swift, such asInt
,Float
,Double
, andBool
.To change the underlying value stored by a
See moreRealmOptional
instance, mutate the instance’svalue
property.Declaration
Swift
@available(*, deprecated, renamed: "RealmProperty", message: "RealmOptional<T> has been deprecated, use RealmProperty<T?> instead.") public final class RealmOptional<Value> : RLMSwiftValueStorage where Value : RealmOptionalType
extension RealmOptional: Equatable where Value: Equatable
extension RealmOptional: Codable where Value: Codable, Value: _RealmSchemaDiscoverable
-
A
RealmProperty
instance represents an polymorphic value for supported types.To change the underlying value stored by a
RealmProperty
instance, mutate the instance’svalue
property.Note
AnRealmProperty
should not be declared as@objc dynamic
on a Realm Object. Uselet
instead.Declaration
Swift
public final class RealmProperty<Value> : RLMSwiftValueStorage where Value : RealmPropertyType, Value : _RealmSchemaDiscoverable
extension RealmProperty: Equatable where Value: Equatable
extension RealmProperty: Codable where Value: Codable, Value: _RealmSchemaDiscoverable