Swift: How To Get Specific Cell in didTapCellAtCoordinate


#1

I stuck for a day in this problem. In prepareCellForDisplay I can get cell using this :

     let textCell = cell as! SDataGridMultiLineTextCell
     
And then i can call this : 
     
     textCell.textLabel.text 

In prepareCellForDisplay there are ‘cell’ parameter, but in didTapCellAtCoordinate there’s no cell. There is a coordinate. How i can get a specific cell using that in didTapCellAtCoordinate function?
Any answer will helpfull for me. Thanks in Advance.


#2

Hi MrX,

The didTapCellAtCoordinate method provides you with a ShinobiDataGrid object as well as the SDataGridCoord, so you can call:

let cell = grid.visibleCell(atCoordinate: gridCoordinate)

Regards,

Alison


#3

Hi aclarke,

Its work without error, but why there is no :
cell.textCell.text

I use editable cell and i want to save the String into a variable

*Edit :

I forgot about the real question. Your answer is a cell, so i get the textCell with :
var textCell = cell as! SDataGridMultiLineTextCell
textCell.textLabel.text

Thanks in Advance


#4

Hi MrX,

If you’re expecting to see the text as entered by the user, you need to use the didFinishEditingCellAtCoordinate: delegate method rather than didTapCellAtCoordinate:.

There’s a full example of editing data grid cells in the samples in your downloaded bundle, called “HandlingEditing”. Although it’s written in Objective-C rather than Swift, it should give you a good idea of which methods to use at which point.

I hope that helps.

Alison