NSTableView in view controller problem

I have a view controller which displays an NSTableView showing a list of names. I create two instances of this view controller in subviews in two different windows. In one window the view controller works fine, in the second it does not!

In the second, the initial load of data works, but when the scroller is moved, the delegate is not called and no new data is displayed (blanks instead). Also, no clicks in the table are recognized in the VC! Below are screen caps of the two windows side by side. The first shows initial loading which is correct. In the second window I have clicked once in the scroll bar. Identical code!

Screen shots just show it does not work as intended. But we need to see code of each viewController to possibly find the cause.

.

Identical code!

That may just be the problem !

``class pInfoViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate {     @IBOutlet var infoTable : NSTableView!

    var artists = artistModel()

@IBAction func tableViewDoubleAction(sender: AnyObject)   {

        let r = infoTable.clickedRow

           aPainterWindow = painterWindow(windowNibName: "painterWindow")

       

        aPainterWindow.setPainter(ID:artists.patienterNID(index:r))

        aPainterWindow.showWindow(self)

    }

    @IBAction func painterClicked(sender : Any)   {

        let r = infoTable.clickedRow

        

          let painterID = artists.patienterNID(index: r)

        print("load paintings for painterID = (painterID).")

          NotificationCenter.default.post(name: NSNotification.Name(rawValue: "loadPaintingsForPainter"), object: painterID )     }

    func reloadDataAndTable()     {

        artists.loadAllPainters()

        self.infoTable.reloadData()

    }

    override func viewDidLoad()     {         super.viewDidLoad()         reloadDataAndTable()     }

    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?     {         let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Painter"), owner: self) as? NSTableCellView

        cell?.textField?.stringValue = artists.itemN(index:row)

        print("piv row=(row). value= (artists.itemN(index:row)).")

        return cell     }    

    func numberOfRows(in aTableView: NSTableView) -> Int       {

      return artists.nItems() }

}.`

`

NSTableView in view controller problem
 
 
Q