<?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 Cynara on Medium]]></title>
        <description><![CDATA[Stories by Cynara on Medium]]></description>
        <link>https://medium.com/@cynaravocosta?source=rss-cfaa3f8854dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vdt-Z3otaTMVRUaq</url>
            <title>Stories by Cynara on Medium</title>
            <link>https://medium.com/@cynaravocosta?source=rss-cfaa3f8854dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 17:31:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cynaravocosta/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[How to add images dynamically with UIImagePickerController into your Swift project]]></title>
            <link>https://medium.com/@cynaravocosta/how-to-add-images-dynamically-with-uiimagepickercontroller-into-your-swift-project-e5c1a868ca12?source=rss-cfaa3f8854dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5c1a868ca12</guid>
            <category><![CDATA[uiimagepickercontroller]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Cynara]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 18:21:04 GMT</pubDate>
            <atom:updated>2022-09-27T18:21:04.727Z</atom:updated>
            <content:encoded><![CDATA[<h4>Before we start</h4><p>This article has been developed using Xcode 13.4.1, and Swift 5.6.1</p><h4>Context</h4><p>I was on a project where I needed the user to add an image from their photo gallery.</p><p>However, I had never done anything like this with UIKit before. That way, I naturally only knew how to manipulate the files by calling their names in the assets folder, but it couldn’t work that way.</p><p>The solution I found was to use the UIImagePickerController and perform some manipulation of the files in the project directories in xcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*-OBkKfnh5TJHJypt1jL26g.gif" /><figcaption>video demonstrating the goal you would like to reach</figcaption></figure><h4>The code</h4><p>First we have to create the UIImagePickerController, which I made programmatically, and set the main basic properties so that it works the way that I wanted it to be, which is like the exposed in the gif above.</p><p>But I’ve created the UIImagePickerController() at a button function, because I want it to pop up after a click at a button, which it is the pattern I guess.</p><p>This way, I set the delegate to <strong>self</strong>, cause I added a extension at the file I was at.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ae52aa372307090e11745f35592cdf8/href">https://medium.com/media/8ae52aa372307090e11745f35592cdf8/href</a></iframe><p>So, the extension code is below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34df63cfcac1271ddfdfceecb006b48b/href">https://medium.com/media/34df63cfcac1271ddfdfceecb006b48b/href</a></iframe><p><strong>Important to say that this is only the code from the adding image, not the entire gif above.</strong></p><p>In a short explanation, if we select a image we’re adding it to the directory so we can use it along the project.</p><p>Each image would have a identifier, which I selected as:</p><pre><strong>let imgName = imageURL?.lastPathComponent</strong> </pre><p>so added in here:</p><pre><strong>let fileURL = documentsURL.appendingPathComponent(imgName!)</strong> </pre><p>after turn the file into a png so could use.</p><p>And, you can use the image calling it with the code:</p><p>Each image would have a identifier, which I selected as:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65b5026b18eabee5b46e8bdf76fab526/href">https://medium.com/media/65b5026b18eabee5b46e8bdf76fab526/href</a></iframe><p>The path for the photo you pass at the spot where is <strong>photo </strong>at the code above, so you call the exactly file.</p><h4>Conclusion</h4><p>This was a reasonably short tutorial. I hope it has helped you in some form anyway!</p><p>For more information about this project you can check the github repository: <a href="https://github.com/CynaraCosta/OrganizArt">https://github.com/CynaraCosta/OrganizArt</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5c1a868ca12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>