<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jeff Garibay on Medium]]></title>
        <description><![CDATA[Stories by Jeff Garibay on Medium]]></description>
        <link>https://medium.com/@quickjeff?source=rss-9c8ffc64b15e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*dWq8s-cC7RSqLGca</url>
            <title>Stories by Jeff Garibay on Medium</title>
            <link>https://medium.com/@quickjeff?source=rss-9c8ffc64b15e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 10:59:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@quickjeff/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Swift iOS Development: How to Pass Data from One Screen to Another]]></title>
            <link>https://medium.com/macoclock/swift-ios-development-how-to-pass-data-from-one-screen-to-another-81bf97e62820?source=rss-9c8ffc64b15e------2</link>
            <guid isPermaLink="false">https://medium.com/p/81bf97e62820</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Jeff Garibay]]></dc:creator>
            <pubDate>Mon, 06 Apr 2020 21:21:42 GMT</pubDate>
            <atom:updated>2020-04-13T15:39:37.392Z</atom:updated>
            <content:encoded><![CDATA[<p>When you begin working with Swift and developing apps for all sorts of businesses or great ideas, you will eventually need to pass data from one view controller to another or as many say, “from one screen to another”.</p><p>In this article, you will learn how to do this with a simple example. The process can seem quite challenging but refill your coffee cup, take a deep breath and know you will pull through this. It’s not that bad!</p><h3>The Project</h3><p>Let’s pretend your app is called Cool Cars. Cool Cars requires you to pass data from a starting view controller that displays a list of vehicles to the destination view controller that shows the selected vehicle details.</p><h3>Setting Up the Segue</h3><p>You will first <strong>control + drag</strong> from the starting view controller to the destination view controller you want to pass data to. Select what kind of segue you want, for this case we are using <strong>show.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4CPPSCn_3CDxj0gGaULug.png" /></figure><p>Next, you will want to give the segue an identifier. You do this by clicking on the arrow that is now going to the destination view controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EqAKSltFBZM8UzJdN6r-eA.png" /></figure><p>In this example, we went with carVCSegue to keep things descriptive. <strong>Meaning: this is the segue to the car view controller.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*K932LwQBRUNdortfeE3ffQ.png" /></figure><p>In order to present the destination view controller, you will want to use the <strong>performSegue method.</strong> You can add this method to an <strong>IBAction. </strong>For this tutorial, let’s use a button action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*12raCe_pwemjZlpknrMC0w.png" /></figure><p>As you can see <strong>we are utilizing the identifier we created</strong> to present the destination view controller <strong>when the button is pressed.</strong></p><p>Now that you have the segue linked from one view controller to the other, it’s time to prepare the data to be passed!</p><h3>Prepare to Pass the Data</h3><p>In the starting view controller, you will want to use the <strong>prepare for segue</strong> method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WmIEwviUqPYhVZd7tIjxmg.png" /></figure><p>Inside this method, you are able to prepare the data that is to be used in the view controller that will be displayed. For the sake of keeping this article short, let&#39;s say we have already created a variable inside of the starting view controller. This variable is called <strong>car</strong>. Let’s also say we have created another variable inside of the destination view controller. This variable is called <strong>selectedCar</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*0wCwFmwAtjYlpgH2A95jDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*rc6d_NoShjT3VwV8J2kB_Q.png" /></figure><p>Now, this is where the magic happens. Inside of your <strong>prepare for segue method,</strong> you will write the code required to pass data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c2a6I7n90y_4rypkbSha3w.png" /></figure><p>When the segue takes place, we are assigning our <strong>destination view controller to the carVC variable.</strong> Then, we are saying that the variable found in the destination view controller is to contain the data from the starting view controller.</p><p><strong>carVC.selectedCar = car</strong></p><p>Now, you can utilize the data in the destination view controller because you have passed the data right over. The data will be available to you through the variable <strong>selectedCar</strong>.</p><p>Now, we can get all sorts of information from <strong>selectedCar.</strong></p><h3>Conclusion</h3><p>In the example that was used above, you would typically have a model that you have created which will hold the car data. For the sake of simplicity, the model information was not included in the example. However, the point being made is to utilize <strong>prepare for segue</strong> to prepare the data and pass the data to your destination view controller.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81bf97e62820" width="1" height="1" alt=""><hr><p><a href="https://medium.com/macoclock/swift-ios-development-how-to-pass-data-from-one-screen-to-another-81bf97e62820">Swift iOS Development: How to Pass Data from One Screen to Another</a> was originally published in <a href="https://medium.com/macoclock">Mac O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>