I
I
i_divided_by_zero2018-01-30 18:25:21
Cocoa
i_divided_by_zero, 2018-01-30 18:25:21

How to determine the data for the table cell (NSTableView) in which the button was clicked?

How to determine the data for the table cell (NSTableView) in which the button was clicked? The (Int) tag is not suitable for these cases, as I work in tandem with the FetchResultController and the deletion / insertion animation. Accordingly, if you assign tag = row when deleting, the tags will not be recalculated taking into account the operation. Only when calling TableView.reloadData(). How can I bind to a cell / NSTextView exactly the value of the corresponding data from the DataSource?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Cherny, 2018-01-31
@freeg0r

If you are working with a FetchResultController, the data is taken from the Core Data table that is being fetched from, and each cell corresponds to the data in the FetchResultController with the corresponding IndexPath, which you can get in cellForRow atIndexPath and fill in the fields. So you don't have to tie anything. Read documentation, study examples.

B
briahas, 2018-02-08
@briahas

Forget about tags(!!!) never use them, avoid them like pranks (...that's what they are).
If you insert a view into a cell after creating the cell, then set up the view in this cell into some kind of property by a weak reference by a delegate or something like that. And on pressing, take a cell from the property. Better not the cell itself, but the cell data that you need.
And, frankly, the task is described crumpled. For good, it is not clear and I answered what I understood from your description.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question