you will need to create a function inside the protocol
protocol DataTransformationDelegate: AnyObject {
func changeFav()
or may be a property you want to change
}
then you can create class where you create a function that in turn calls this function in protocoal and performs any action you want
class FavAction{
weak var delegate:DataTransformationDelegate?
func callFavToPlay() {
delegate?.changeFav()
// or may be update the property you want to change
}
}
Now you can use extension to adopt the DataTransformationDelegate
protocol in the viewcontroller
Create an instance of FavAction class and call the method callFavToPlay.
As it is called it will trigger, what you have done in
func callFavToPlay() {
delegate.changeFav()
// or may be update the property you want to change
}
so you now update or receive a value and use it inside the ViewController which has adopted DataTransformationDelegate
you can the use the value you will receive from this function to update
so this way you can use delegate pattern , when you pass the responsibilty and then when then responsibilty is fulfilled you get a the value in return that you want and use it inside the viewcontroller that adopts that protocol which declares that responsibility .