Instance Property インスタンスプロパティ

coordinator

An object you use to communicate your AppKit view controller’s behavior and state out to SwiftUI objects.

Declaration 宣言

let coordinator: ViewController.Coordinator

Discussion 議論

The coordinator is a custom object you define. When updating your view controller, communicate changes to SwiftUI by updating the properties of your coordinator, or by calling relevant methods to make those changes. The implementation of those properties and methods are responsible for updating the appropriate SwiftUI values. For example, you might define a property in your coordinator that binds to a SwiftUI value, as shown in the following code example. Changing the property updates the value of the corresponding SwiftUI variable. コーディネータは、あなたが定義するあつらえのオブジェクトです。あなたがビューコントローラを更新する時、変更をSwiftUIに伝えてください、あなたのコーディネータのプロパティを更新することによって、または関連メソッドを呼び出してそれら変更をなすことによって。それらプロパティおよびメソッドの実装は、適切なSwiftUI値を更新することに対して責任をもちます。例えば、あなたはプロパティをあなたのコーディネータの中で定義するかもしれません、それはSwiftUI値へとバインドするものです、以下のコード例で示されるように。プロパティを変更することは、対応するSwiftUI変数の値を更新します。


class Coordinator: NSObject {
   @Binding var rating: Int
   init(rating: Binding<Int>) {
      $rating = rating
   }
}

To create and configure your custom coordinator, implement the makeCoordinator() method of your NSViewControllerRepresentable object.

See Also 参照

Coordinating View-Related Interactions ビュー関連相互作用と協調する