{"id":16699727,"url":"https://github.com/gonzalezreal/reusable","last_synced_at":"2025-04-10T03:42:33.947Z","repository":{"id":63910953,"uuid":"208809068","full_name":"gonzalezreal/Reusable","owner":"gonzalezreal","description":"iOS cell registration and reusing with generics and protocol extensions","archived":false,"fork":false,"pushed_at":"2020-01-12T09:31:43.000Z","size":7,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T05:01:45.985Z","etag":null,"topics":["cell","collectionview","ios","protocol-extension","swift","tableview"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/gonzalezreal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-16T13:38:26.000Z","updated_at":"2023-06-25T12:39:40.000Z","dependencies_parsed_at":"2022-11-29T07:16:42.443Z","dependency_job_id":null,"html_url":"https://github.com/gonzalezreal/Reusable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FReusable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FReusable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FReusable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FReusable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gonzalezreal","download_url":"https://codeload.github.com/gonzalezreal/Reusable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154964,"owners_count":21056541,"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":["cell","collectionview","ios","protocol-extension","swift","tableview"],"created_at":"2024-10-12T18:08:03.406Z","updated_at":"2025-04-10T03:42:33.927Z","avatar_url":"https://github.com/gonzalezreal.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reusable\n\n![Swift 5.1](https://img.shields.io/badge/Swift-5.1-orange.svg)\n[![Swift Package Manager](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager)\n[![Twitter: @gonzalezreal](https://img.shields.io/badge/twitter-@gonzalezreal-blue.svg?style=flat)](https://twitter.com/gonzalezreal)\n\nReusable is a Swift µpackage that provides a type-safe way for cell registration and dequeuing in both table and collection views. It is based on [this post](https://gonzalezreal.github.io/2015/12/31/ios-cell-registration-reusing-with-swift-protocol-extensions-and-generics.html) I wrote a few years ago while I was exploring some of the Swift language features.\n\n## Usage\n\nTo be able to register and reuse a cell or supplementary view in a type-safe way, the view must conform to the `ReusableView` protocol:\n\n```Swift\nextension PosterItemCell: ReusableView {}\n```\n\nThe default implementation of `ReusableView` will provide a reuse identifier based on the class name.\n\nCells implemented with **Interface Builder** must also conform to the `NibLoadableView` protocol:\n\n```Swift\nextension PosterItemCell: ReusableView, NibLoadableView {}\n```\n\nOnce the cell or supplementary view is ready, you can register it in a collection or table view by indicating its type:\n\n```Swift\nfunc viewDidLoad() {\n  super.viewDidLoad()\n  collectionView.register(PosterItemCell.self)\n  ...\n}\n```\n\nLikewise, you can dequeue a cell previously registered in this way just by indicating its type:\n\n```Swift\nfunc collectionView(_: UICollectionView, cellForItemAt indexPath: IndexPath) -\u003e UICollectionViewCell {\n    let cell = collectionView.dequeueReusableCell(PosterItemCell.self, for: indexPath)\n    ...\n    return cell\n}\n```\n\n## Installation\n**Using the Swift Package Manager**\n\nAdd Reusable as a dependency to your `Package.swift` file. For more information, see the [Swift Package Manager documentation](https://github.com/apple/swift-package-manager/tree/master/Documentation).\n\n```\n.package(url: \"https://github.com/gonzalezreal/Reusable\", from: \"1.0.0\")\n```\n\n## Help \u0026 Feedback\n- [Open an issue](https://github.com/gonzalezreal/Reusable/issues/new) if you need help, if you found a bug, or if you want to discuss a feature request.\n- [Open a PR](https://github.com/gonzalezreal/Reusable/pull/new/master) if you want to make some change to `Reusable`.\n- Contact [@gonzalezreal](https://twitter.com/gonzalezreal) on Twitter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Freusable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgonzalezreal%2Freusable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Freusable/lists"}