jeudi 30 janvier 2020

Where should UICollectionView/UITableView delegate/datasource functions go in Clean Swift [Uncle Bob's Clean Architecture]

I recently switched my app over from MVC to Clean Swift and i'm having trouble deciding in which classes to put certain things. For example, should the delegate/datasource functions for a UICollectionView/UITableView go in the Interactor, or Presenter? Or maybe certain functions, like didSelectItemAt should go in the Interactor because they deal with input, and others, like cellForItemAt, should go in the Presenter because they deal with views.

What are your decision making processes when deciding where to put certain functionality in Clean Swift?`

Currently I have the following in my ViewController

{
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 
    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
    func scrollViewDidScroll(_ scrollView: UIScrollView)

}

the following in my Interactor

{
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
}

and the following in my 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 
}

Aucun commentaire:

Enregistrer un commentaire