Недавно я переключил свое приложение с MVC
на Clean Swift
, и мне трудно решить, в какие классы поместить определенные вещи. Например, должны ли функции delegate
/datasource
для UICollectionView
/UITableView
идти в Interactor
или Presenter
? Или, может быть, некоторые функции, такие как didSelectItemAt
, должны быть в Interactor
, потому что они имеют дело с вводом, а другие, например cellForItemAt
, должны быть в Presenter
, потому что они имеют дело с представлениями.
Каковы ваши процессы принятия решений, когда вы решаете, где разместить определенные функции в Clean Swift
?`
В настоящее время у меня есть следующее в моем ViewController
{
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
func scrollViewDidScroll(_ scrollView: UIScrollView)
}
следующее в моем Interactor
{
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
}
и следующее в моем Presenter
{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
}