{"id":21272704,"url":"https://github.com/genkernel/treeview","last_synced_at":"2025-07-11T06:32:31.426Z","repository":{"id":7472088,"uuid":"8819986","full_name":"genkernel/TreeView","owner":"genkernel","description":"\"TreeView - sub-cells simplified\" (c). Enable subcells in UITableView with a single drop-in extension. CocoaPod: ","archived":false,"fork":false,"pushed_at":"2022-10-20T22:40:21.000Z","size":1001,"stargazers_count":55,"open_issues_count":1,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-08T05:51:52.767Z","etag":null,"topics":["collapsable","collapse","concept","expand","expandable","expandablelistview","expandabletableview","indexpath","ios","nsindexpath","objective-c","subtree","swift","tree-node","treeview","uitableview","uitableviewcell","uitableviewdatasource"],"latest_commit_sha":null,"homepage":"http://cocoapods.org/pods/treeview","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/genkernel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-16T14:36:12.000Z","updated_at":"2025-04-27T14:35:29.000Z","dependencies_parsed_at":"2022-07-09T15:47:13.666Z","dependency_job_id":null,"html_url":"https://github.com/genkernel/TreeView","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/genkernel/TreeView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkernel%2FTreeView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkernel%2FTreeView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkernel%2FTreeView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkernel%2FTreeView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genkernel","download_url":"https://codeload.github.com/genkernel/TreeView/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkernel%2FTreeView/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264747905,"owners_count":23657926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collapsable","collapse","concept","expand","expandable","expandablelistview","expandabletableview","indexpath","ios","nsindexpath","objective-c","subtree","swift","tree-node","treeview","uitableview","uitableviewcell","uitableviewdatasource"],"created_at":"2024-11-21T09:08:44.188Z","updated_at":"2025-07-11T06:32:31.117Z","avatar_url":"https://github.com/genkernel.png","language":"Objective-C","readme":"\n**TreeView is iOS single-class component written in ObjC that enables cell + subcells support for UITableView-s.**\n\n- Project status\n- Examples\n- Documentation\n\n\nCurrent status\n---\nTreeView was initially written in 2012 and has been used in multiple projects since then.\nDevelopment is finalized, component and its public API is considered stable.\n\nThe most convenient way to use it is via CocoaPods:\n```ruby\npod 'TreeView'\n```\nAletrnativelly you may simply drop **TreeView/TreeTable.h,m** into your project.\n\nExamples\n---\nPreview on Youtube: http://youtu.be/zS3gQ4pnmBs\n\nYou may find demo iOS app with 3 working modules in _'Examples'_ directory:\n  - inSwift-4.2\n  - fileSystem-asTree\n  - plist-allExpanded-byDefault\n\n\nDocumentation\n---\n\nIn basic MVC scenario ViewController is set as DataSource of UITableView.\n\nTreeView package introduces single new class: TreeTable.\nIt is designed to sit in between ViewController and UITableView as a DataSource object that knows how to work with subcells via deeper \"nested\" indexPaths.\n\nTreeTable implements UITableViewDataSource protocol and represents inner subcells with indexPaths of deeper levels. For instance cell at 0-0 indexPath may contain 3 subcells: 0-0-0, 0-0-1, 0-0-2.\n\nIn plan MVC example: TreeTable is a \"proxy\" object that sits between tableView and a viewController, proxies all calls to data source and converts 2d-like indexPaths (0-0, 0-1, ...)  into N-depth indexPaths (0-0, 0-0-1, 0-0-2, 0-1-0-1, ...) to represent subcells.\n\nYou usually decide to use TreeTable component when your \u003cb\u003eUITableViewCell\u003c/b\u003e wants to contain its own subcells that can be easily expanded or collapsed.\u003cbr /\u003e\n\nImplementation details\n---\n\nTreeTable adds 2 logical states to every cell: \u003cb\u003eexpanded\u003c/b\u003e and \u003cb\u003ecollapsed\u003c/b\u003e.\n\nYou should expand a cell to reveal its subcells.\u003cbr/\u003e\n\nKeeping this in mind helper methods(as UITableView category) were implemented: \u003cbr/\u003e\n```swift\nfunc expand(treeIndexPath: IndexPath)\nfunc isExpanded(treeIndexPath: IndexPath) -\u003e Bool\nfunc collapse(treeIndexPath: IndexPath)\n```\n\nInstead of implementing \u003cb\u003eUITableViewDataSource\u003c/b\u003e in your controller - implement \u003cb\u003eTreeTableDataSource\u003c/b\u003e. TreeTableDataSource protocol extends UITableViewDataSource by introducing 2 new required methods:\u003cbr/\u003e\n```swift\nfunc tableView(_ tableView: UITableView, isCellExpandedAt treeIndexPath: IndexPath) -\u003e Bool\nfunc tableView(_ tableView: UITableView, numberOfSubCellsForCellAt treeIndexPath: IndexPath) -\u003e Int\n```\n\nNotice all \u003cb\u003erequired\u003c/b\u003e dataSource methods are invoked with indexPath of N-depth that uniquely identify cell or subcell.\u003cbr/\u003e\nHence you should change behaviour of the following methods:\n```swift\nfunc tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -\u003e Int\nfunc tableView(tableView: UITableView, cellForRowAt treeIndexPath: IndexPath) -\u003e UITableViewCell\n```\n\nand use \n```swift\nfunc tableIndexPathFromTreePath(treeIndexPath: IndexPath) -\u003e IndexPath\n```\nif you need to convert N-depth index path into 2d index path.\n\nOn the other hand all \u003cb\u003eoptional\u003c/b\u003e methods are transparently forwarded to your implementations (if you provide any) and indexPath parameter is not changed - it is 2d indexPath.\nYou can convert it into N-depth treeIndexPath with:\n```swift\nfunc treeIndexPathFromTablePath(indexPath: NSIndexPath) -\u003e NSIndexPath\n```\nmethod.\n\n\nConcept image\n---\n\n![Concept](https://github.com/genkernel/TreeView/raw/master/concept.jpg)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenkernel%2Ftreeview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenkernel%2Ftreeview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenkernel%2Ftreeview/lists"}