footyapps27
footyapps27

Reputation: 4042

passing data using delegates between viewcontrollers without any navigation controller connection

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 Bnavigates 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.

Upvotes: 5

Views: 9938

Answers (3)

Dnyaneshwar Shinde
Dnyaneshwar Shinde

Reputation: 187

For Send data from second view controller to First Controller use following github project:-

https://github.com/mauli787/CustomDelegateDataPassing

Upvotes: 0

Anton K
Anton K

Reputation: 344

You can use some singleton class and implement delegate protocol in it. So you will have opportunity to pass data between any view controllers.

Upvotes: 1

Paresh Navadiya
Paresh Navadiya

Reputation: 38249

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.

Upvotes: 8

Related Questions