|
I have a collectionView and there is a button on the each cell. and when I tap the button, I'd like to display a table view cell with the data the coooection view cell had usning the delegate pattern. I'd appreciate your help. this is the collectionViewCell class:
this is the table view controller that I wanna show the cell that I chose as favorite:
|
|
you will need to create a function inside the protocol
then you can create class where you create a function that in turn calls this function in protocoal and performs any action you want
Now you can use extension to adopt the Create an instance of FavAction class and call the method callFavToPlay. As it is called it will trigger, what you have done in
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 . |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.