Skip to content

Commit

Permalink
add bundle var on CollectionCellDescribable to enable using collor in…
Browse files Browse the repository at this point in the history
… external frameworks
  • Loading branch information
Guihal Gwenn authored and Guihal Gwenn committed Mar 7, 2018
1 parent e01385d commit 1f6d97f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Collor/Classes/CollectionCellDescribable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public protocol CollectionCellDescribable : Identifiable {
var selectable: Bool { get }
func getAdapter() -> CollectionAdapter
func size(_ collectionView: UICollectionView, sectionDescriptor: CollectionSectionDescribable) -> CGSize
var bundle: Bundle { get }
}

extension CollectionCellDescribable {
Expand All @@ -32,3 +33,10 @@ extension CollectionCellDescribable {
}
}
}

public extension CollectionCellDescribable {
var bundle: Bundle {
let typeClass = type(of: self)
return Bundle(for: typeClass)
}
}
2 changes: 1 addition & 1 deletion Collor/Classes/CollectionDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CollectionDataSource: NSObject, UICollectionViewDataSource {
let cellDescriptor = collectionData.sections[indexPath.section].cells[indexPath.item]

if collectionData.registeredCells.contains(cellDescriptor.identifier) == false {
let nib = UINib(nibName: cellDescriptor.className, bundle: nil)
let nib = UINib(nibName: cellDescriptor.className, bundle: cellDescriptor.bundle)
collectionView.register(nib, forCellWithReuseIdentifier: cellDescriptor.identifier)
collectionData.registeredCells.insert(cellDescriptor.identifier)
}
Expand Down

0 comments on commit 1f6d97f

Please sign in to comment.