what is delegate? we created delegate for solve what problem? how is delegate important?
What is delegate?
The delegation is the capability for an object to ask another object to perform some task on its behalf by delegating to him.
Consider the case of UITableView.
When you create, you declare (generally) its parent class as its delegate.
Now, you can adapt funds, like didSelect, inside the view Controller, without having to change code in UITableView.
Another case is when you want to update a fixed in a VC from another VC. delegate is a clean way to do it.
Delegation is a very important mechanism to understand and practice. Search for tutorials, like this one
h ttps :// www.appcoda. com/swift-delegate/
Consider the case of UITableView.
When you create, you declare (generally) its parent class as its delegate.
Now, you can adapt funds, like didSelect, inside the view Controller, without having to change code in UITableView.
Another case is when you want to update a fixed in a VC from another VC. delegate is a clean way to do it.
Delegation is a very important mechanism to understand and practice. Search for tutorials, like this one
h ttps :// www.appcoda. com/swift-delegate/
Does this solve your question? They have a comprehensive tutorial on this, and possible other alternative methods.
https://codermite.com/t/tutorial-communication-between-views-loosely-coupled-delegation/246