title: View-Based NSTableView in Swift - How to
body: <p>I have a <strong>NSTableView</strong> whose cells are <strong>view-based</strong>.</p>
  
  <p><em>DataSource &amp; Delegate are connected</em>, but I'm <strong>not able to display the cell's textField string value</strong>.</p>
  
  <p>This is the code in <strong>Objective-C, working</strong>:</p>
  
  <pre><code>- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
  
  return 10;
  
  }
  
  - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
  
          NSTableCellView *cell = [tableView makeViewWithIdentifier:@"List" owner:self];
          [cella.textField setStringValue:"Hey, this is a cell"];
  
          return cell;
  }
  </code></pre>
  
  <p>And here is my code in <strong>Swift, not working</strong> : </p>
  
  <pre><code>func numberOfRowsInTableView(aTableView: NSTableView!) -&gt; Int
  {
      return 10 //Casual number
  }
  func tableView(tableView: NSTableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -&gt; NSTableCellView! {
      var cell = tableView.makeViewWithIdentifier("List", owner: self) as NSTableCellView!
      // setup cell without force unwrapping it
      cell.textField.stringValue = "Hey, this is a cell"
      println("Method called") //Never printed
      return cell
  }
  </code></pre>
  
  <p>This is the result: (table on right side of image)</p>
  
  <p>Note that the comment <code>//setup cell without force unwrapping it</code> makes no sense, I forgot to delete it.</p>
  
  <p><img src="https://i.stack.imgur.com/5uVOc.png" alt="Code + Result">
  <img src="https://i.stack.imgur.com/jBCfh.png" alt="TableVie settings">
  <img src="https://i.stack.imgur.com/fOkZy.png" alt="Delegate and DataSource connected"></p>
  
  <h2>What I am missing ?</h2>
  
  <p><strong><em>Edit</em></strong>: I tried even the following with no success:</p>
  
  <pre><code>func numberOfRowsInTableView(aTableView: NSTableView!) -&gt; Int
  {
      return 10
  }
  func tableView(tableView: NSTableView!, objectValueForTableColumn tableColumn: NSTableColumn!, row: Int) -&gt; AnyObject
  {
      var cell = tableView.makeViewWithIdentifier("List", owner: self) as NSTableCellView
      cell.textField.stringValue = "Hey this is a cell"
      return cell;
  }
  </code></pre>
  
  <hr>
  
  <p>Thank you all.
  Alberto</p>