swift - NSTableView's makeViewWithIdentifier finding nil on one of its child views -
i have nstableview 2 columns, 1 non-editable nstextfield , other editable one. each cell has different identifier ("camera" first column, "position" other).
i having no trouble first column's cell, however, second 1 ("position") finds nil when trying access editable nstextfield. have tried using 1 identifier. declaring @ beginning of viewfortablecolumn, , several other things, keeps missing nstextfield. ideas might going wrong?
my code:
func tableview(tableview: nstableview, viewfortablecolumn tablecolumn: nstablecolumn?, row: int) -> nsview? { if tablecolumn?.identifier == "column0" { let cell = tableview.makeviewwithidentifier("camera", owner: nil) as? nstablecellview cell?.textfield?.stringvalue = array(cameraorder.keys)[row] return cell } else { let cell = tableview.makeviewwithidentifier("position", owner: nil) as? nstablecellview cell!.textfield!.stringvalue = string(array(cameraorder.values)[row]) //this 1 finding nil return cell } }
my views:
i found way it, although don't know if optimal:
it seems having 2 textfields reason making code crash. using identifier of first column ("camera") , taking modifying label fit needs. ends happening, instance of first text field created in second column cell, has properties need.
let cell = tableview.makeviewwithidentifier("camera", owner: nil) as? nstablecellview //...set of first column, , without changing identifiers..// cell?.textfield?.delegate = self cell?.textfield!.placeholderstring = "position here" cell!.textfield!.editable = true cell!.textfield!.stringvalue = string(array(cameraorder.values)[row]) return cell
Comments
Post a Comment