Open frogcjn opened 8 years ago
I'm not the author, but I can let you know how we are working with this.
We add callbacks and things to our cell models for when certain subviews are tapped. We don't want the CellModel to know or care about the TableView or Hakuba... it is basically an inert object that just holds data.
So when we need to care about its index path and such, we deal with it at a different level. For example, one way we do it is like this:
private func blogPostCellModel(blog: BlogPost, indexPath: NSIndexPath) -> MYCellModel {
let model = BlogPostCellModel(blog)
model.wasSelectedHandler = { [weak self] in
self?.openBlogPostView(blog)
self?.tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
return model
}
Hopefully you can get something like this set up in your case as well. I personally don't think models should know about views, so this is one way we found to keep them separated (in the controller).
@cjwirth , thanks! I'll try it.
It is inconvenient to de-highlight row when a row has been selected
the cellModel has no information about the table and hakuba object, so it is hard to dehighlight the row after it has been selected.