{"id":17655725,"url":"https://github.com/mergesort/GenericCells","last_synced_at":"2025-03-11T00:31:40.235Z","repository":{"id":38325771,"uuid":"77358224","full_name":"mergesort/GenericCells","owner":"mergesort","description":"Creating generic UITableViewCells and UICollectionViewCells instead of subclasses.","archived":false,"fork":false,"pushed_at":"2021-01-17T15:13:27.000Z","size":40,"stargazers_count":82,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-01T19:26:13.460Z","etag":null,"topics":["uicollectionview","uitableview"],"latest_commit_sha":null,"homepage":"","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/mergesort.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-12-26T04:39:54.000Z","updated_at":"2024-03-10T15:04:41.000Z","dependencies_parsed_at":"2022-08-25T03:01:57.922Z","dependency_job_id":null,"html_url":"https://github.com/mergesort/GenericCells","commit_stats":null,"previous_names":["mergesort/generictablecell"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FGenericCells","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FGenericCells/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FGenericCells/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FGenericCells/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mergesort","download_url":"https://codeload.github.com/mergesort/GenericCells/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242950884,"owners_count":20211569,"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":["uicollectionview","uitableview"],"created_at":"2024-10-23T13:01:41.540Z","updated_at":"2025-03-11T00:31:40.224Z","avatar_url":"https://github.com/mergesort.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# GenericCells\n\n#### Creating UITableViewCell and UICollectionViewCell subclasses is so Swift 2 point zero.\n\n[![Pod Version](https://img.shields.io/badge/Pod-1.4.1-6193DF.svg)](https://cocoapods.org/)\n![Swift Version](https://img.shields.io/badge/Swift-5.1-brightgreen.svg)\n![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg) \n![Plaform](https://img.shields.io/badge/Platform-iOS-lightgrey.svg)\n\n---\n\nIntroducing, GenericCells!… Capitalizing on Swift's generics, we can get all the benefits of a custom UITableViewCell or UICollectionViewCell class, without the hassle of a new class for each of them.\n\n---\n\n#### Let's show you how to use it.\n\nCreate a UIView subclass for the layout you want:\n\n```swift\nfinal class MyView: UIView {\n\n    let imageView: UIImageView\n    let titleLabel: UILabel\n    let subtitleLabel: UILabel\n    // And add more views to your heart's content\n\n}\n```\n\nRegister the cell with a UITableView **or** UICollectionView:\n\n```swift\ntableView.register(GenericTableCell\u003cMyView\u003e.self)\n```\n```swift\ncollectionView.register(GenericCollectionCell\u003cMyView\u003e.self)\n```\n\nDequeue the cell with a UITableView **or** UICollectionView:\n\n```swift\nlet cell = tableView.dequeueReusableCell(forIndexPath: indexPath) as GenericTableCell\u003cMyView\u003e\n```\n```swift\nlet cell = collectionView.dequeueReusableCell(forIndexPath: indexPath) as GenericCollectionCell\u003cMyView\u003e\n```\n\nAnd customize it to your heart's content. The view you wish to access will be available via the `.customView` property:\n\n```swift\ncell.customView.titleLabel.text = \"This library rules!\"\ncell.customView.imageView.image = UIImage(named: \"success\")\n```\n\nExtra credit, let's add recycling support. Extend your view with the `ReusableGenericView` protocol:\n\n```swift\nextension MyView: ReusableGenericView {\n\n    func prepareForReuse() {\n        self.titleLabel.text = \"\"\n        self.subtitleLabel.text = \"\"\n        self.imageView.image = nil\n    }\n\n}\n```\n\nAnd it will get called when the cell is recycled.\n\n## Installation\n\nYou can use [SPM](https://swift.org/package-manager/) to install `GenericCells`.\n\nYou can also use [CocoaPods](http://cocoapods.org/) to install `GenericCells` by adding it to your `Podfile`:\n\n```swift\nplatform :ios, '9.0'\nuse_frameworks!\n\npod 'GenericCells'\n```\n\nOr install it manually by downloading `GenericTableCell.swift`, `GenericCollectionCell.swift`, and `ReusableView.swift`, and dropping it in your project.\n\n## About me\n\nHi, I'm [Joe](http://fabisevi.ch) everywhere on the web, but especially on [Twitter](https://twitter.com/mergesort).\n\n## License\n\nSee the [license](LICENSE) for more information about how you can use GenericCells.\n\n## Is that it?\n\nYes, that's it. And if you don't like it, well sorry, here's a rainbow. 🌈\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmergesort%2FGenericCells","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmergesort%2FGenericCells","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmergesort%2FGenericCells/lists"}