LinkedInAttic / LayoutKit

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
http://layoutkit.org
Apache License 2.0
3.16k stars 267 forks source link

tableview - get selected row model #101

Closed cliren closed 7 years ago

cliren commented 7 years ago

When tableView.dataSource = reloadableViewLayoutAdapter which takes a array of Layout items ( a subclass of InsetLayout), how do I get selected model data from the below table view delegate? do I need to hold on to model reference inside my layout class?

class MyReloadableViewLayoutAdapter: ReloadableViewLayoutAdapter {

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let item = currentArrangement[indexPath.section].items[indexPath.item]
    print("items: \(item)")
  }
}
staguer commented 7 years ago

I'd keep a separate data structure of view models or domain models and handle the user interactions at that level. The Layout items I'd use just for producing a UI representation of the current state.