Now i'm trying to learn about Clean Swift architecture.
I'm using DataStore
to passing data to next viewController
and calling backward-viewController's interactor
to do something when I want to send data backward like delegation
.
I don't sure that this is suit with architecture. Please show me how.
I know that it is good to use DataStore
for passing data FORWARD to next viewController
. But is it good to use DataStore
for passing data BACKWARD?
As all of my tableViewCells
, collectionViewCells
, etc. using delegation
to sending any actions or datas to it's viewController
, Will it be good and less confusing to use delegation
for sending data BACKWARD too?
Thanks!
Using Delegation is the preferred way to do it in iOS, because it allows you to keep code components decoupled. The current view controller should not be really concerned who is its delegate, whether it's another view controller or some coordinator.
To recap:
For passing data backwards, we can also use Closure Properties, but personally I am not a big fan of doing it this way.