Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is inconvenient to de-highlight row when a row has been selected #17

Open
frogcjn opened this issue Nov 10, 2015 · 2 comments
Open

Comments

@frogcjn
Copy link

frogcjn commented Nov 10, 2015

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.

@cjwirth
Copy link

cjwirth commented Nov 11, 2015

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).

@frogcjn
Copy link
Author

frogcjn commented Nov 11, 2015

@cjwirth , thanks! I'll try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants