I'm trying to set up a custom class for an NSTableView and seem to be almost there with it.
When I run this code I get an error message : Could not cast value of type 'NSTableCellView' (0x7fff7a859af0) to 'NSTableViewTest.MyCellView' (0x10001e480) in the line "let cell = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self) as! MyCellView!"
import Cocoa
class Table1: NSTableView, NSTableViewDataSource, NSTableViewDelegate
{
override func drawRect(dirtyRect: NSRect)
{
super.drawRect(dirtyRect)
}
func numberOfRowsInTableView(tableView: NSTableView) -> Int
{
return 10
}
func tableView(tableView: NSTableView, heightOfRow row: Int) -> CGFloat
{
return 25
}
func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView?
{
let cell = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self) as! MyCellView!
return cell
}
}
with my cell class defined as :
import Cocoa
class MyCellView: NSView
{
@IBOutlet weak var itemName: NSTextField!
@IBOutlet weak var itemDescription: NSTextField!
@IBOutlet weak var itemImage: NSImageView!
}