Passing data between ViewControllers via Delegate & Protocols

Jay Mayu
4 min readJul 18, 2017

We all know how to pass data between ViewControllers via the prepareForSegue method. It has it’s own limitations and advantages. The good news is, it’s not the only way you can pass data between ViewControllers.

One of the most popular and common methods to pass data between ViewControllers is via the Delegate and Protocols. Before starting this tutorial, if you haven’t already, please read my article on Protocol. If you understand Protocol then this article would make more sense.

Instead of talking too much let’s dive into an example and see how it’s done.

Let’s create a Single Page Application named “Spy and Base”.

Now delete the default ViewController.Swift and create two more ViewControllers named “HomeBaseVC” and “EnemyBaseVC”

After creating the ViewControllers, it should look like below.

It’s time to do some changes in the StoryBoard. Let’s open storyboard and change the…

--

--