title: binding NSPopupbutton to an array of classes
body: <p>I'm having difficulty binding a NSPopUpButton to an NSArrayController.
  The array controller manages an array (plants) of the the class Plant, which has a property named commonName which should be listed in the button. I've searched for several days and I'm unable to discover why this isn't working. I'm able to get the button to display the elements of an array of strings but not with the plants array. When the program runs, the button has no elements and doesn't react to clicking.</p>
  <p>I've included a screenshot of the attributes and bindings but here's a description:</p>
  <p>ArrayController</p>
  <ol>
  <li>Attributes: Mode = Class; Class Name = TestDB.Plant (TestDB is the
  name of the project)</li>
  <li>Binding: Bound to View Controller; Model Key
  Path = plants</li>
  </ol>
  <p>Button Bindings</p>
  <ol>
  <li>Content: Bound to Array Controller; Controller Key = arrangedObjects</li>
  <li>Content Values: Bound to Array Controller; Controller Key =
  arrangedObjects; Model Key Path = objectValue.commonName</li>
  </ol>
  <p>Here is the code from the ViewController:</p>
  <pre><code>class ViewController: NSViewController {
  
  @IBInspectable var plants: [Plant] = []
  @IBOutlet weak var plantPopUp: NSPopUpButton!
  
      override func viewDidLoad() {
              super.viewDidLoad()
  
          //the real list will be pulled from a database, but I'm using
          //this to test binding the button
          plants = [Plant(commonName: &quot;Asparagus&quot;, scientificName: &quot;Asparagus officials&quot;), 
            Plant(commonName: &quot;Beet&quot;, scientificName: &quot;Beta vulgaris&quot;)]
  
          //to redraw the button?? Doesn't change anything with or without
          plantPopUp.needsLayout.true
      }   
  }
  </code></pre>
  <p>This is the code for the class Plant:</p>
  <pre><code>@objc class Plant: NSObject {
      @objc dynamic var commonName: String
      @objc dynamic var scientificName: String
  
      init(commonName: String, scientificName: String) {
          self.commonName = commonName
          self.scientificName = scientificName
      }
  }
  </code></pre>
  <p>Here are screenshots of the attributes and bindings of the NSArrayController and the NSPopupButton. Very grateful for any help.</p>
  <p><img src="https://i.stack.imgur.com/diJu8.png" alt="Attributes and Bindings" /></p>