collect result of NStableView with checkboxes in Swift

338 views Asked by At

I have hard time trying to collect the number of checkboxes checked inside the second column of a NStableView.

I composed a NSTableView with 2 column (via IB), the first is named : BugColumn (it contains textfiled) the second is named : CheckedColumn (it contains checkboxes)

Here is the code used to display strings in the first column :

var objets: NSMutableArray! = NSMutableArray()

...

extension MasterViewController: NSTableViewDataSource
{    


func numberOfRowsInTableView(aTableView: NSTableView) -> Int
{

    return self.objets.count

}


func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView?
{

    var cellView: NSTableCellView = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self) as! NSTableCellView

        if tableColumn!.identifier == "BugColumn"
        {
        cellView.textField!.stringValue = self.objets.objectAtIndex(row) as! String
        }


    return cellView
}

The second column is made of checkboxes appearing for each element of the first column.

I would like to know what is the corresponding text in the first column for each checkboxes enabled (checked).

I red a few exemples about NSTableView but, or they do differents things, or they are in Objective-C. Could someone explain how to do that using swift? Thanks

0

There are 0 answers