Skip to content

Commit

Permalink
Added Header/Footer register+dequeue to UITableView
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrommcarrasco committed Mar 29, 2019
1 parent 58568d9 commit dfb6ee1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sucrose.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.swift_version = "5.0"
s.name = "Sucrose"
s.version = "3.1.0"
s.version = "3.1.1"
s.summary = "🍬 Everyday sugar"
s.description = "Collection of handy methods & objects"

Expand Down
2 changes: 1 addition & 1 deletion Sucrose/Extensions/UICollectionView+Cell.swift
Expand Up @@ -14,7 +14,7 @@ public extension UICollectionView {
register(T.self, forCellWithReuseIdentifier: T.name)
}

func dequeue<T: UICollectionViewCell>(for indexPath: IndexPath, as type: T.Type) -> T {
func dequeue<T: UICollectionViewCell>(_ type: T.Type, for indexPath: IndexPath) -> T {
guard let cell = self.dequeueReusableCell(withReuseIdentifier: type.name, for: indexPath) as? T else {
fatalError("Unknown Cell at \(indexPath)")
}
Expand Down
4 changes: 2 additions & 2 deletions Sucrose/Extensions/UITableView+Cell.swift
Expand Up @@ -18,15 +18,15 @@ public extension UITableView {
register(T.self, forHeaderFooterViewReuseIdentifier: T.name)
}

func dequeue<T: UITableViewCell>(for indexPath: IndexPath, as type: T.Type) -> T {
func dequeue<T: UITableViewCell>(_ type: T.Type, in indexPath: IndexPath) -> T {
guard let cell = self.dequeueReusableCell(withIdentifier: type.name, for: indexPath) as? T else {
fatalError("Unknown Cell at \(indexPath)")
}

return cell
}

func dequeue<T: UITableViewHeaderFooterView>(as type: T.Type) -> T {
func dequeue<T: UITableViewHeaderFooterView>(_ type: T.Type) -> T {
guard let view = self.dequeueReusableHeaderFooterView(withIdentifier: T.name) as? T else {
fatalError("Couldn't dequeue Header/Footer named \(T.name)")
}
Expand Down

0 comments on commit dfb6ee1

Please sign in to comment.