There are many examples of passing data between two view controllers, where one view controller navigates to another view controller.
But is it possible to pass data using custom protocols & delegates between view controllers that are not connected by navigation controller?
So, an example could be: Three view controllers namely are, A
,B
,C
. A
navigates to B
, and B
navigates to C
. I know how to pass data between A
& B
using custom protocols & delegates. But can we pass data between C
& A
. Thus A
can be C
's delegate and thereby can receive data from C
. Is this possible?
Any help would be appreciated.
Pass Data using Seque. After outlet is connected to respective viewController, select Enter Last Name button and then CTRL + Drag to NextViewController(i.e, FirstViewController) for showing the viewController from LandingPageViewController. This lets you set what kind of segue you want to use.
One way is use delegates for backward passing of data
Refer simple-delegate-tutorial-for-ios link for passing data from C to A controller.
Check basic-delegate-example link.
Another way is by posting notification. for backward passing of data
Check Comunicate-Two-Views link.
You can use some singleton class and implement delegate protocol in it. So you will have opportunity to pass data between any view controllers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With