ios - 我应该在哪里用 VIPER 在 UICollectionView 中的 didSelectItemAt 中编写逻辑?
问题描述
我有一个带有 VIPER 的 UICollectionView:
//MARK: - UICollectionViewDataSource
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return presenter?.getCertsCount(status: getCertStatus()) ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? MyCertificationCell {
if let certs = presenter?.getCerts(status: getCertStatus()) {
cell.cert = certs[indexPath.item]
}
return cell
}
return UICollectionViewCell()
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
}
但是当didSelectItemAt发出网络请求或推送新的 ViewController 时,我应该在哪里编写逻辑。在Presenter或Interactor或ViewModel中?
解决方案
推荐阅读
- arrays - 如何在 bash 脚本中使用动态值
- javascript - 请使用 Javascript 更改 IFRAME 中的元素,或发现此代码中的错误
- javascript - 如何在 JavaScript 中对项目进行分组以不超过总量?
- r - 如何清理和组织这个抓取数据列表?
- python - “系统找不到指定的路径”:Anaconda Geopandas 安装问题
- python - find_elements_by_xpath 的第二次迭代在 selenium python 中给出错误
- c++ - 删除和添加函数之间的循环
- spring-boot - 如何在具有相同事实的 Spring Drools 中使用多个决策表(excel 文件)
- telegram - 将 Telegraf 连接到本地 Bot API 服务器?
- postgresql - postgresql 使用对称密钥加密并滚动它