The second table view cells are being populated with "Table View Cell" even though the inActiveComputers array is populated.
tableView1 is successfully populated with the activeComputers array. both tables have the datasource, delegate, and referencing outlets set to MainView though IB.
I'm at a loss on what to try next!
@IBOutlet weak var tableView1: NSTableView!
@IBOutlet weak var tableView2: NSTableView!
func numberOfRows(in tableView: NSTableView) -> Int {
if(tableView == self.tableView1){
return activeComputers.count
}
else if(tableView == self.tableView2){
return inActiveComputers.count
}
return 0
}
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
var result = NSTableCellView()
if(tableView == self.tableView1)
{
result = tableView.makeView(withIdentifier: (tableColumn?.identifier)!, owner: self) as! NSTableCellView
result.textField?.stringValue = activeComputers[row][(tableColumn?.identifier.rawValue)!]!
return result
}
else if(tableView == self.tableView2)
{
result = tableView.makeView(withIdentifier: (tableColumn?.identifier)!, owner: self) as! NSTableCellView
result.textField?.stringValue = inActiveComputers[row][(tableColumn?.identifier.rawValue)!]!
return result
}
return nil
}
I've also tried this...
func numberOfRows(in tableView: NSTableView) -> Int {
if tableView == tableView1 {
return activeComputers.count
} else { return deadComputers.count}
}
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
var result = NSTableCellView()
result = tableView.makeView(withIdentifier: (tableColumn?.identifier)!, owner: self) as! NSTableCellView
if tableView == tableView1 {
result.textField?.stringValue = activeComputers[row][(tableColumn?.identifier.rawValue)!]!
} else {
result.textField?.stringValue = deadComputers[row][(tableColumn?.identifier.rawValue)!]!
}
return result
}
I put a breakpoint on } else {
The content in else in the tableView function just gets skipped right over. I feel like what I'm trying to achieve isn't possible with this approach!?
THANKS FOR THE TIPS
I needed to set the Referencing Outlets for the second table's nested textField's. I had this set on my first table but forgot about it on the second. I'm now able to parse the each array to each table. (See the picture below)