ObservedResults

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@propertyWrapper
public struct ObservedResults<ResultType> : DynamicProperty, BoundCollection where ResultType : KeypathSortable, ResultType : RealmFetchable, ResultType : _ObservedResultsValue, ResultType : Identifiable

영역에서 쿼리의 결과를 나타내는 속성 래퍼 유형입니다.

결과는 환경 값 realmConfiguration 에서 제공하는 영역 구성을 사용합니다.

SwiftUI가 아닌 결과 collection과 달리 ObservedResults는 변경 가능합니다. ObservedResults collection에 대한 쓰기는 암시적으로 쓰기 트랜잭션 (write transaction)을 수행합니다. 관련 쿼리에서 필터링할 객체를 ObservedResults에 추가하면 객체가 영역에 추가되지만 ObservedResults에는 포함되지 않습니다.

@ObservedResults var v SwiftUI에서 이$v 주어지면 은 BoundCollection 를 나타냅니다.

  • 선언

    스위프트

    public typealias Element = ResultType
  • 결과 필터링에 사용되는 NSPredicate를 저장합니다. 이는 where 매개변수와 상호 배타적입니다.

    선언

    스위프트

    @State
    public var filter: NSPredicate? { get nonmutating set }
  • 결과 필터링에 사용되는 형식 안정 쿼리를 저장합니다. 이는 filter 매개변수와 상호 배타적입니다.

    선언

    스위프트

    @State
    public var `where`: ((Query<ResultType>) -> Query<Bool>)? { get nonmutating set }
  • 지정된 Projection 유형에 대한 ObservedResults 구조체를 초기화합니다.

    선언

    스위프트

    public init<ObjectType: ObjectBase>(_ type: ResultType.Type,
                                        configuration: Realm.Configuration? = nil,
                                        filter: NSPredicate? = nil,
                                        keyPaths: [String]? = nil,
                                        sortDescriptor: SortDescriptor? = nil) where ResultType: Projection<ObjectType>, ObjectType: ThreadConfined

    매개변수

    type

    관찰된 유형

    configuration

    Realm을 만들 때 Realm.Configuration 사용되며, 지정된 파티션 값에 대한 사용자의 동기화 구성은 syncConfiguration 로 설정되고, 비어 있으면 구성이 defaultConfiguration로 설정됩니다.

    filter

    통과하는 객체에 대해서만 관찰이 수행됩니다. 필터를 지정하지 않으면 모든 객체가 관찰됩니다.

    keyPaths

    키 경로 배열에 포함된 속성만 관찰됩니다. nil 인 경우 객체의 속성 변경에 대한 알림이 전달됩니다. 유효한 속성에 해당하지 않는 문자열 키 경로는 예외를 발생시킵니다.

    sortDescriptor

    정렬 기준이 되는 SortDescriptor의 시퀀스입니다.

  • 지정된 Object 또는 EmbeddedObject 유형에 대한 ObservedResults 구조체를 초기화합니다.

    선언

    스위프트

    public init(_ type: ResultType.Type,
                configuration: Realm.Configuration? = nil,
                filter: NSPredicate? = nil,
                keyPaths: [String]? = nil,
                sortDescriptor: SortDescriptor? = nil) where ResultType: Object

    매개변수

    type

    관찰된 유형

    configuration

    Realm을 만들 때 Realm.Configuration 사용되며, 지정된 파티션 값에 대한 사용자의 동기화 구성은 syncConfiguration 로 설정되고, 비어 있으면 구성이 defaultConfiguration로 설정됩니다.

    filter

    통과하는 객체에 대해서만 관찰이 수행됩니다. 필터를 지정하지 않으면 모든 객체가 관찰됩니다.

    keyPaths

    키 경로 배열에 포함된 속성만 관찰됩니다. nil 인 경우 객체의 속성 변경에 대한 알림이 전달됩니다. 유효한 속성에 해당하지 않는 문자열 키 경로는 예외를 발생시킵니다.

    sortDescriptor

    정렬 기준이 되는 SortDescriptor의 시퀀스입니다.

  • 지정된 Object 또는 EmbeddedObject 유형에 대한 ObservedResults 구조체를 초기화합니다.

    선언

    스위프트

    public init(_ type: ResultType.Type,
                configuration: Realm.Configuration? = nil,
                where: ((Query<ResultType>) -> Query<Bool>)? = nil,
                keyPaths: [String]? = nil,
                sortDescriptor: SortDescriptor? = nil) where ResultType: Object

    매개변수

    type

    관찰된 유형

    configuration

    Realm을 만들 때 Realm.Configuration 사용되며, 지정된 파티션 값에 대한 사용자의 동기화 구성은 syncConfiguration 로 설정되고, 비어 있으면 구성이 defaultConfiguration로 설정됩니다.

    where

    통과하는 객체에 대해서만 관찰이 수행됩니다. 유형 안전 쿼리가 제공되지 않은 경우 - 모든 객체가 관찰됩니다.

    keyPaths

    키 경로 배열에 포함된 속성만 관찰됩니다. nil 인 경우 객체의 속성 변경에 대한 알림이 전달됩니다. 유효한 속성에 해당하지 않는 문자열 키 경로는 예외를 발생시킵니다.

    sortDescriptor

    정렬 기준이 되는 SortDescriptor의 시퀀스입니다.

  • 선언

    스위프트

    nonisolated public func update()