{"id":21063398,"url":"https://github.com/mohsinaliayub/indexedtableview","last_synced_at":"2025-08-25T01:43:31.100Z","repository":{"id":164362069,"uuid":"481926444","full_name":"mohsinaliayub/IndexedTableView","owner":"mohsinaliayub","description":"A table view which displays index on the trailing side of the screen, allowing easy navigation to sections.","archived":false,"fork":false,"pushed_at":"2022-04-15T11:03:43.000Z","size":1245,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T20:47:18.469Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohsinaliayub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-15T10:45:11.000Z","updated_at":"2022-04-15T10:45:29.000Z","dependencies_parsed_at":"2023-06-09T21:30:12.343Z","dependency_job_id":null,"html_url":"https://github.com/mohsinaliayub/IndexedTableView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsinaliayub%2FIndexedTableView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsinaliayub%2FIndexedTableView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsinaliayub%2FIndexedTableView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsinaliayub%2FIndexedTableView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohsinaliayub","download_url":"https://codeload.github.com/mohsinaliayub/IndexedTableView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243505894,"owners_count":20301619,"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":[],"created_at":"2024-11-19T17:44:59.106Z","updated_at":"2025-03-14T01:22:28.801Z","avatar_url":"https://github.com/mohsinaliayub.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IndexedTableView\nA table view which displays index on the trailing side of the screen, allowing easy navigation to sections.\n\n# Description\nWhen dealing with a large number of records, it is simple and effective to organize data into sections and provide an index list for easy access.\nWe populated the data using a **UITableViewDiffableDataSource** and used its sectionIndexTitles(for: UITableView) method to provide sections.\n\nHere is the code that displays section title, index title and index to the section for easy access.\n```swift\nclass AnimalTableDataSource: UITableViewDiffableDataSource\u003cString, String\u003e {\n    override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -\u003e String? {\n        snapshot().sectionIdentifiers[section]\n    }\n\n    override func sectionIndexTitles(for tableView: UITableView) -\u003e [String]? {\n        snapshot().sectionIdentifiers\n    }\n\n    override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -\u003e Int {\n        index\n    }\n}\n```\n\nJust use this custom diffable data source class to create cells and populate data.\n```swift\nlet dataSource = AnimalTableDataSource(tableView: tableView) { tableView, indexPath, animalName in\n    let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\", for: indexPath)\n\n    // configure the cell\n    cell.textLabel?.text = animalName\n\n    // ...\n    return cell\n}\ntableView.dataSource = dataSource\n```\n\nFinally, you will need to create a snapshot, append sections and items to it, and apply the snapshot to the above data source. ```animalsDict``` is\na dictionary of type ```[String: String]``` and ```animalSectionTitles``` is an array of String.\n```swift\n\nvar snapshot = NSDiffableDataSourceSnapshot\u003cString, String\u003e()\n    snapshot.appendSections(animalSectionTitles) // append our sections\n    animalSectionTitles.forEach { section in\n      if let animals = animalsDict[section] {\n          snapshot.appendItems(animals, toSection: section) // for each section, add the items corresponding to that section.\n      }\n}\n\ndataSource.apply(snapshot)\n\n```\n\n# Screenshots\nHere's how the app looks.\n\n\u003cimg src=\"/Screenshots/App.png\" width=\"231\" height=\"500\" alt=\"Indexed Table View\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsinaliayub%2Findexedtableview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohsinaliayub%2Findexedtableview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsinaliayub%2Findexedtableview/lists"}