I have an NSTableView whose cells are based on views .
DataSource and Delegate are connected, but I am not able to display the string value of a textField cell .
This is the code in Objective-C that works :
- (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; }
And here is my code in Swift, not working :
func numberOfRowsInTableView(aTableView: NSTableView!) -> Int { return 10 //Casual number } func tableView(tableView: NSTableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> 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 }
This is the result: (table on the right side of the image)
Please note that the comment //setup cell without force unwrapping it does not make sense, I forgot to delete it.



What am I missing?
Change I tried even the following without success:
func numberOfRowsInTableView(aTableView: NSTableView!) -> Int { return 10 } func tableView(tableView: NSTableView!, objectValueForTableColumn tableColumn: NSTableColumn!, row: Int) -> AnyObject { var cell = tableView.makeViewWithIdentifier("List", owner: self) as NSTableCellView cell.textField.stringValue = "Hey this is a cell" return cell; }
Thanks to everyone. Alberto
source share