title: Column oriented Data of Object in NSTable
body: <p>I'm trying to fill my <code>NSTable</code> with informations from an object array but column oriented. The default table orientation is by row. So, each object information is presented by row:</p>
  
  <p><a href="https://i.stack.imgur.com/r9g9j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r9g9j.png" alt="row oriented object data in NSTableView"></a></p>
  
  <p>But I need to present the object information by column:</p>
  
  <p><a href="https://i.stack.imgur.com/nonxa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nonxa.png" alt="column oriented object data in NSTableView"></a></p>
  
  <p>I do not understand how to achieve this. What if the number of columns is variable at runtime and how to show the object data column oriented? The standard <code>NSDataSourceProtocol</code> with reusing cells/views is not useful in my case:</p>
  
  <pre><code>func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -&gt; Any? {
  
    var text: String = ""
    var cellIdentifier: String = ""
  
    guard let item = modelObjectArray?[row] else {
      return nil
    }
  
     if tableColumn == tableView.tableColumns[0] {
       let text = item.name
       cellIdentifier = "someIdentifier"
      } else if ...{
         ...
      }
  
     if let cell = tableView.make(withIdentifier: cellIdentifier, owner: nil) as? NSTableCellView {
       cell.textField?.stringValue = text
       return cell
     }
  return nil
  }
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Thanks!</p>