{"id":19535340,"url":"https://github.com/romansorochak/reusable","last_synced_at":"2025-04-26T14:35:47.390Z","repository":{"id":62452192,"uuid":"95014325","full_name":"romansorochak/Reusable","owner":"romansorochak","description":"Easy way to create/reuse custom cells \u0026 headers with xib written in Swift","archived":false,"fork":false,"pushed_at":"2020-01-31T18:58:37.000Z","size":23,"stargazers_count":27,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T13:17:32.849Z","etag":null,"topics":["cell","collectionview","custom","dequeue","ios","reusable","reuse","swift","tableview","xib"],"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/romansorochak.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":"2017-06-21T14:41:04.000Z","updated_at":"2021-02-21T12:55:02.000Z","dependencies_parsed_at":"2022-11-01T23:34:24.670Z","dependency_job_id":null,"html_url":"https://github.com/romansorochak/Reusable","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romansorochak%2FReusable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romansorochak%2FReusable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romansorochak%2FReusable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romansorochak%2FReusable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romansorochak","download_url":"https://codeload.github.com/romansorochak/Reusable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251001428,"owners_count":21520944,"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","custom","dequeue","ios","reusable","reuse","swift","tableview","xib"],"created_at":"2024-11-11T02:18:06.857Z","updated_at":"2025-04-26T14:35:47.130Z","avatar_url":"https://github.com/romansorochak.png","language":"Swift","readme":"# Reusable\nEasy way to setup custom cells with xib\n\n## Contents\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Author](#author)\n- [License](#license)\n\n## Requirements\n\n- iOS 8.0+\n- Xcode 8.0+\n- Swift 3.0+\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.1.0+ is required to build Reusable 1.0.0+.\n\nTo integrate Reusable into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'RSReusable'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n## Usage\n\nMake sure you name your cell's class and xib with the same names \n\n- MyCell.swift:\n```swift\nclass MyCell: UITableViewCell, Reusable {\n```\n\n- MyCell.xib\n\n### UITableViewCell\n#### Custom table cell with xib\n1) Make cell to implement Reusable protocol\n```swift\nimport Reusable\n//...\nclass MyCell: UITableViewCell, Reusable {\n```\n2) (optional) Make cusom xib cell and set cell's class to MyCell\n3) Dequeue cell\n```swift\nimport Reusable\n//...\nfunc tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -\u003e UITableViewCell {\n    let cell = tableView.dequeue(forIndexPath: indexPath) as MyCell\n    \n    //setup cell ...\n    \n    return cell    \n}\n```\n#### Custom table header (footer) with xib\n1) Make header (footer) to inherit from BaseTableSectionHeaderFooterView class\n```swift\nimport Reusable\n//...\nclass MySectionHeaderView: BaseTableSectionHeaderFooterView {\n```\n2) (optional) Make cusom xib view and set file's owner to your class name - MySectionHeaderView\n3) Dequeue header (footer) view \n```swift\nimport Reusable\n//...\nfunc tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -\u003e UIView? {\n    let header = tableView.dequeueHeaderFooterView() as MySectionHeaderView\n\n    //setup header ...\n    \n    return header\n}\n```\n\n### UICollectionViewCell\n#### Custom collection cell with xib\n1) Make cell to implement Reusable protocol\n```swift\nimport Reusable\n//...\nclass MyCollectionCell: UICollectionViewCell, Reusable {\n```\n2) (optional) Make cusom xib cell and set cell's class to MyCollectionCell\n3) Dequeue cell\n```swift\nimport Reusable\n//...\nfunc collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -\u003e UICollectionViewCell {\n    let cell = collectionView.dequeueCell(for: indexPath) as MyCollectionCell\n    \n    //setup cell ...\n    \n    return cell    \n}\n```\n#### Custom collection header with xib\n1) Make header (footer) to implement Reusable protocol\n```swift\nimport Reusable\n//...\nclass CollectionHeaderView: UICollectionReusableView, Reusable {\n```\n2) (optional) Make cusom xib view (UICollectionReusableView) and set it's class to CollectionHeaderView\n3) Dequeue view \n```swift\nimport Reusable\n//...\nfunc collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -\u003e UICollectionViewCell {\n    let cell = collectionView.dequeueCell(for: indexPath) as CollectionHeaderView\n\n    //setup header ...\n    \n    return header\n}\n```\n\n## Author\nRoman Sorochak - iOS developer. You may contact me via email: roman.sorochak@gmail.com\n\n## License\n\nReusable is released under the MIT license. See [LICENSE](https://github.com/romansorochak/Reusable/blob/master/LICENSE) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromansorochak%2Freusable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromansorochak%2Freusable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromansorochak%2Freusable/lists"}