title: Setting Background Color of NSTableCellView in Swift
body: <p>After searching through SO and online, I'm struggling to figure out a concept that I thought would be relatively simple.  Essentially, I have a table in an OS X Swift app, with several columns, and it is currently populating data.  I am trying to discern how I can set the background color of each "row" (ideally with alternating colors, but I'll start with just one color).  My MasterViewController file is like so;</p>
  
  <pre><code>import Cocoa
  
  class MasterViewController: NSViewController {
  
  var minions = [Minion]()
  
  func setupSampleMinion() {
      minions = Minion.fetchMinionData()
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do view setup here.
  }
  
  }
  
  // MARK: - NSTableViewDataSource extension MasterViewController: NSTableViewDataSource {
  func numberOfRowsInTableView(aTableView: NSTableView) -&gt; Int {
      return self.minions.count
  }
  
  func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -&gt; NSView? {
  
      // 1
      var cellView: NSTableCellView = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self) as! NSTableCellView
  
      let minion = self.minions[row]
  
      // 2
      if tableColumn!.identifier == "MyColumn" {
          // 3
  
          cellView.imageView!.image = NSImage(named: "minion.name!")
          cellView.textField!.stringValue = minion.name!
          return cellView
      }
  
      return cellView
  }
  }
  
  func tableView(tableView: NSTableView, rowViewForRow row: Int) -&gt; NSTableRowView? {
  let myCustomView = MyRowView()
  return myCustomView
  }
  
  class MyRowView: NSTableRowView {
  
  override func drawRect(dirtyRect: NSRect) {
      super.drawRect(dirtyRect)
  
      self.backgroundColor = NSColor(red: 0.76, green: 0.82, blue: 0.92, alpha: 1)
  
      NSRectFill(dirtyRect)
  
  
  }
  }
  
  // MARK: - NSTableViewDelegate extension MasterViewController: NSTableViewDelegate {
  }
  </code></pre>
  
  <p>While I THINK I have some of the coding right, this does not seem to set the background color if the row in any way.  Any thoughts or overall guidance would be most appreciated.  Thank you!</p>