SimpleCell
A Swift Extension for Reusable Collection View and TableView Cell.
Summary
Before
tableView.register(UItableViewCell, forCellWithReuseIdentifier: "Cell")
tableView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! UserCell
It can cause a mistake if writing an identifier manually.
After
tableView.register(cell: TableViewCell.self)
let cell = tableView.dequeue(TableViewCell.self)
an identifier is generated automatically with the same name as its class name.
Usage
TableView
// 1. register
tableView.register(cell: TableViewCell.self)
// 2. dequeue
tableView.dequeue(TableViewCell.self)
// or
tableView.dequeue(TableViewCell.self, indexPath: indexPath)
CollectionView
// 1. register
collectionView.register(cell: CollectionViewCell.self)
// or when using supplementary views.
collectionView.register(cell: CollectionReusableView.self, forSupplementaryViewOfKind: .header)
collectionView.register(cell: CollectionReusableView.self, forSupplementaryViewOfKind: .footer)
// 2. dequeue
collectionView.dequeue(CollectionView.self)
// or when using supplementary views.
collectionView.dequeue(CollectionReusableHeaderView.self, .header, indexPath: indexPath)
collectionView.dequeue(CollectionReusableFooterView.self, .footer, indexPath: indexPath)
Requirements
SimpleCell requires iOS 8 or above and is written in Swift 5.0
Installation
CocoaPods
CaseContainer is available through CocoaPods. To install it, simply add the following line to your podfile:
pod 'SimpleCell', '~> 0.6.0'
And run pod install
.
Carthage
CaseContainer is available through Carthage. Simply install carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
add CaseContainer to your Cartfile
:
github "devmjun/SimpleCell" ~> 0.6.0
And run carthage update
.
Contributing
Bug reports, pull request and any discussion are welcome
License
SimpleCell is available as open source under the terms of the MIT License