Open jadar opened 10 years ago
You can ask the tableview for the index path for the cell:
__weak typeof(self) weakSelf = self;
[self.sizeManager registerCellClassName:NSStringFromClass([TableViewCell class])
withNibNamed:nil
forObjectClass:[CellData class]
configurationBlock:^(TableViewCell *cell, CellData *object) {
NSIndexPath *indexPath = [weakSelf.tableView indexPathForCell:cell];
// ... do something with index path ...
}];
Yes but that returns nil. I assume because the cell has not yet been added to the table view due to the height being called before the cell is added. Or do I have the order of things wrong?
Nope, you're totally right, that was my oversight. If you'd like to add the index path to the block signatures, please do so and open a pull request. That would be a welcome enhancement.
I'd be happy to. Should I just add an extra block signature or change the current one?
Hmm. I'd say change the current one, but then it will not be backwards compatible. But that's much better than having duplicate signatures for everything so go ahead and change it. We can release it as a major version update.
Thanks!
Is there a way to get the index path of the cell I'm currently configuring? My configuration code relies on the index path in part of it. I already tried [tableView indexPathForCell:cell] and that returned nil.