Tutorial by Examples

To pass data from the current view controller to the next new view controller (not a previous view controller) using segues, first create a segue with an identifier in the relevant storyboard. Override your current view controller's prepareForSegue method. Inside the method check for the segue you j...
To pass data from the current view controller back to the previous view controller, you can use the delegate pattern. This example assumes that you have made a segue in the Interface Builder and that you set the segue identifier to showSecondViewController. The outlets and actions must also be ho...
In contrast to segue that lets you pass data "forward" from current view controller to destination view controller: (VC1) -> (VC2) Using "unwind" you can do the opposite, pass data from the destination or current view controller to its presenting view controller: (VC1) <...
Instead of using the delegate pattern, that split the implementation in various part of the UIViewController class, you can even use closures to pass data back and forward. By assuming that you're using the UIStoryboardSegue, in the prepareForSegue method you can easily setup the new controller in ...
this topic is a classical issue in iOS development, and its solution is various as other example already shown. In this example I'll show another daily common use one: passing data using closure by adapting delegate pattern example on this page into callback closure! one thing this method is superi...
You can pass data directly by assigning the property of the next view controller before you push or present it. class FirstViewController: UIViewController { func openSecondViewController() { // Here we initialize SecondViewController and set the id property to 492 let se...

Page 1 of 1