Results
@frozen
public struct Results<Element> : Equatable, RealmCollectionImpl where Element : RealmCollectionValue
extension Results: RealmSubscribable
extension Results: Encodable where Element: Encodable
Results
is an auto-updating container type in Realm returned from object queries.
Results
can be queried with the same predicates as List<Element>
, and you can
chain queries to further filter query results.
Results
always reflect the current state of the Realm on the current thread, including during write transactions on
the current thread. The one exception to this is when using for...in
enumeration, which will always enumerate over
the objects which matched the query when the enumeration is begun, even if some of them are deleted or modified to be
excluded by the filter during the enumeration.
Results
are lazily evaluated the first time they are accessed; they only run queries when the result of the query is
requested. This means that chaining several temporary Results
to sort and filter your data does not perform any
unnecessary work processing the intermediate state.
Once the results have been evaluated or a notification block has been added, the results are eagerly kept up-to-date, with the work done to keep them up-to-date done on a background thread whenever possible.
Results instances cannot be directly instantiated.
-
A human-readable description of the objects represented by the results.
Declaration
Swift
public var description: String { get }
-
Returns the object at the given
index
.Declaration
Swift
public subscript(position: Int) -> Element { get }
Parameters
index
The index.
-
Declaration
Swift
public static func == (lhs: Results<Element>, rhs: Results<Element>) -> Bool
-
A publisher that emits Void each time the collection changes.
Despite the name, this actually emits after the collection has changed.
Declaration
Swift
public var objectWillChange: RealmPublishers.WillChange<Results> { get }