title: Swift UI not redrawing NSViewRepresentable wrapped textfield
body: <p>I created a list-detail view like this. In the detail view, there is some input field that accepts text. The input field is a <code>NSTextField</code> wrapped using <code>NSViewRepresentable</code>. The issue happens in the below scenario.</p>
  <p>First, click a row and select person A. Then try to edit another person's properties by selecting a newer person B. But here the update happens of the first person's properties (A's).</p>
  <p><a href="https://i.stack.imgur.com/PLjQp.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PLjQp.gif" alt="enter image description here" /></a></p>
  <pre><code>struct ContentView: View {
      @State var selectedItem: Person?
      var body: some View {
          HStack {
              List(selection: $selectedItem) {
                  ForEach(modelData, id: \.self) {  person in
                      Text(person.firstName)
                  }
              }
              .border(.separator, width: 1)
              .listStyle(.plain)
              .padding()
              .frame(width: 200)
              
              VStack {
                  if let selectedItem = selectedItem {
                      InformationView(person: PersonModel(person: selectedItem))
                  } else {
                      Text(&quot;No Item Selected&quot;).foregroundColor(Color(NSColor.tertiaryLabelColor))
                  }
              }
              .frame(width: 300)
              .padding()
          }
      }
  }
  </code></pre>
  <p>InformationView</p>
  <pre><code>struct InformationView: View {
      @ObservedObject var person: PersonModel
  
      var body: some View {
          Form {
              NSTextFieldRepresentable(placeholder: &quot;&quot;, text: $person.person.firstName)
              NSTextFieldRepresentable(placeholder: &quot;&quot;, text: $person.person.secondName)
              NSTextFieldRepresentable(placeholder: &quot;&quot;, text: $person.person.city)
          }
      }
  }
  </code></pre>
  <p>NSTextFieldRepresentable</p>
  <pre><code>struct NSTextFieldRepresentable: NSViewRepresentable {
      let placeholder: String
      @Binding var text: String
      
      func makeNSView(context: Context) -&gt; NSTextField {
          let view = NSTextField()
          view.delegate = context.coordinator
          return view
      }
          
      func updateNSView(_ nsView: NSTextField, context: Context) {
          nsView.stringValue = text
          nsView.placeholderString = NSLocalizedString(placeholder, comment: &quot;&quot;)
      }
      
      func makeCoordinator() -&gt; NSTextFieldCoordinator {
          NSTextFieldCoordinator(textField: self)
      }
  
      class NSTextFieldCoordinator: NSObject, NSTextFieldDelegate {
          var textField: NSTextFieldRepresentable
          init(textField: NSTextFieldRepresentable) {
              self.textField = textField
          }
          
          func controlTextDidChange(_ obj: Notification) {
              textField.text = (obj.object as? NSTextField)?.stringValue ?? &quot;&quot;
          }
      }
  }
  </code></pre>
  <p>Model class</p>
  <pre><code>class Person: NSObject, Identifiable {
      
      var id = UUID()
      var firstName: String
      var secondName: String
      var city: String
      
      init (firstName: String, secondName: String, city: String) {
          self.firstName = firstName
          self.secondName = secondName
          self.city = city
      }
  }
  
  
  var modelData: [Person] = [
      Person(firstName: &quot;Lionel&quot;, secondName: &quot;Messi&quot;, city: &quot;Paris&quot;),
      Person(firstName: &quot;Cristiano&quot;, secondName: &quot;Ronaldo&quot;, city: &quot;Manchester&quot;),
      Person(firstName: &quot;Sachin&quot;, secondName: &quot;Tendulkar&quot;, city: &quot;Mumbai&quot;),
      Person(firstName: &quot;Virat&quot;, secondName: &quot;Kohli&quot;, city: &quot;Delhi&quot;)
  ]
  
  class PersonModel: ObservableObject {
      @Published var person: Person
      init(person: Person) {
          self.person = person
      }
      
  }
  </code></pre>