ResultsObserver
class · iOS 27.0+ · SDK 27.1
final class ResultsObserver<Element, SectionTitle> where Element : PersistentModel, SectionTitle : HashableObserves and tracks changes to a collection of persistent models in a model context. `ResultsObserver` automatically monitors changes to models that match specified fetch criteria, providing real-time updates when the underlying data changes. The observer maintains a collection of fetched results, making it ideal for keeping user interfaces synchronized with persistent data. The observer responds to changes from multiple sources: - Local changes made within the same model context - Remote changes from other contexts within the same container - External changes from other processes or CloudKit sync You can configure the observer using either a complete `FetchDescriptor` or individual filter predicates and sort descriptors. The observer is `Observable`, allowing SwiftUI views to automatically update when results change. Use `Never` as the `SectionTitle` type parameter when no sectioning is needed: ```swift let observer = try ResultsObserver<Book, Never>( filterBy: #Predicate { $0.isPublished }, sortBy: [SortDescriptor(\.title)], modelContext: context ) ``` Use a concrete type (e.g. `String`) when sectioning by a key path of that type: ```swift let observer = try ResultsObserver<Book, String>( sectionBy: \.genre, modelContext: context ) ```
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
15 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
ResultsObserver.sectionBy
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.element(at:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.indexPath(for:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(fetchDescriptor:modelContext:isolation:)
The containing type needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(filterBy:sortBy:modelContext:isolation:)
The containing type needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(fetchDescriptor:modelContainer:isolation:)
The containing type needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(filterBy:sortBy:modelContainer:isolation:)
The containing type needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(fetchDescriptor:sectionBy:modelContext:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(filterBy:sortBy:sectionBy:modelContext:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(fetchDescriptor:sectionBy:modelContainer:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(filterBy:sortBy:sectionBy:modelContainer:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(fetchDescriptor:sectionBy:modelContext:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(filterBy:sortBy:sectionBy:modelContext:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(fetchDescriptor:sectionBy:modelContainer:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)
ResultsObserver.init(filterBy:sortBy:sectionBy:modelContainer:isolation:)
This declaration needs Swift generic type arguments. (no canonical witness for Element)