I want to know how to pass data using closure. I know that there are three types of data pass approaches:
delegate
Notification Center
closure
I want proper clarification of closure with an example.
I want to know how to pass data using closure. I know that there are three types of data pass approaches:
delegate
Notification Center
closure
I want proper clarification of closure with an example.
This example explains use of service call with Alamofire and send the response back to calling View Controller with closure.
Code in Service Wrapper Class:
Closure declaration
Closure implementation in method
Code at calling view controller:
Well passing data with blocks / closures is a good and reasonable approach and much better than notifications. Below is the same code for it.
First ViewController (where you make object of Second ViewController)
Second ViewController (where data is passed back to First VC)