Supported Property Types - iOS SDK¶
Property Cheat Sheet¶
New in version 10.8.0:
When declaring default values for
@Persisted UUID or ObjectId property
attributes, both of these syntax types are valid:
@Persisted var value: UUID
@Persisted var value = UUID()
However, the second will result in poorer performance. This is because the latter creates a new identifier that is never used any time an object is read from the realm, while the former only creates them when needed.
@Persisted var id: ObjectId has equivalent behavior to
var _id = ObjectId.generate(). They both make random ObjectIds.
@Persisted var _id = ObjectId() has equivalent behavior to
dynamic var _id = ObjectId(). They both make zero-initialized ObjectIds.
Data and string properties cannot hold more than 16MB. To store larger amounts of data, either:
- Break the data into 16MB chunks, or
- Store data directly on the file system and store paths to the files in the realm.
Realm throws a runtime exception if your app attempts to store more than 16MB in a single property.
To avoid size limitations and a performance impact, it is best not to store large blobs, such as image and video files, directly in a realm. Instead, save the file to a file store and keep only the location of the file and any relevant metadata in the realm.