tableview - View-Based NSTableView in Swift - How to -
i have nstableview cells view-based.
datasource & delegate connected, i'm not able display cell's textfield string value.
this code in objective-c, working:
- (nsinteger)numberofrowsintableview:(nstableview *)tableview { homecoming 10; } - (nsview *)tableview:(nstableview *)tableview viewfortablecolumn:(nstablecolumn *)tablecolumn row:(nsinteger)row { nstablecellview *cell = [tableview makeviewwithidentifier:@"list" owner:self]; [cella.textfield setstringvalue:"hey, cell"]; homecoming cell; }
and here code in swift, not working :
func numberofrowsintableview(atableview: nstableview!) -> int { homecoming 10 //casual number } func tableview(tableview: nstableview!, cellforrowatindexpath indexpath: nsindexpath!) -> nstablecellview! { var cell = tableview.makeviewwithidentifier("list", owner: self) nstablecellview! // setup cell without forcefulness unwrapping cell.textfield.stringvalue = "hey, cell" println("method called") //never printed homecoming cell }
this result: (table on right side of image)
note comment //setup cell without forcefulness unwrapping it
makes no sense, forgot delete it.
what missing ?
edit: tried next no success:
func numberofrowsintableview(atableview: nstableview!) -> int { homecoming 10 } func tableview(tableview: nstableview!, objectvaluefortablecolumn tablecolumn: nstablecolumn!, row: int) -> anyobject { var cell = tableview.makeviewwithidentifier("list", owner: self) nstablecellview cell.textfield.stringvalue = "hey cell" homecoming cell; }
thank all. alberto
after hours of search, discovered method works !
func tableview(tableview: nstableview, viewfortablecolumn: nstablecolumn, row: int) -> nsview { var cell = tableview.makeviewwithidentifier("list", owner: self) nstablecellview cell.textfield.stringvalue = "hey, cell" homecoming cell; }
tableview swift cell
No comments:
Post a Comment