Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Closure is an important part of the swift language, it has the various use & implementation in swift, here I will provide the one use where you can use to communicate between two-controller.
There is a scenario where we will perform some operation on 2nd controller & get their data in the previous controller for this we can use protocol for this, but we can use closure for this
and reduced the unwanted code & improve the readability.
For more usability & implementation you can read this:
https://docs.swift.org/swift-book/LanguageGuide/Closures.html
ViewController1 -> ViewController2 .
Notes: Here we have used 2 controllers, the user will go from viewcontroller1 to viewcontroller2 here it will perform some operation & get back with data to viewcontroller1
Here, actually we need some data from “PinAddressController” that will return through “LocationData” Object so we just return this data to caller controller as input param in a Closure.
When the user will click on the done button then we will dismiss the controller or you can pop back to the previous controller after that return the data.
This controller will present the viewcontroller2 or above the controller.
Notes:
When you will click on getDatataFromOtherController button then it will present the destination controller & after done the second controller which is already on above you will
get the data in “userData”
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.