JWMixedList
示例
要运行示例项目,请克隆仓库,然后首先从Example目录中运行pod install
为什么?
✅ 数据无关的UITableViewControllers✅ 数据无关的UICollectionViewControllers✅ 围绕数据源更好的抽象层✅ 更容易进行测试
如果您曾经编写过以下代码
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell: UICollectionViewCell
if indexPath.item == 0 {
cell = collectionView.dequeue(someCell) as! TypeA
cell.configure()
} else if indexPath.item == 2 {
cell = collectionView.dequeue(someCell) as! TypeB
cell.configure()
} else {
fatalError("This is getting long...")
}
return cell
}
您可能从将逻辑抽象为Item Controllers中受益。通过拥有一些FeedDataType
枚举并切换它来移除所有这些逻辑。
查看示例项目了解其实现方式以及您可能从中获得的益处。
贡献
这个库不支持一些功能,并面临一些挑战。如果您有解决方案,请提出PR!
安装
JWMixedList 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'JWMixedList'
作者
Joe Williams
许可证
JWMixedList 在 MIT 许可证下提供。更多信息请参阅 LICENSE 文件。