<?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 Roberto Breve on Medium]]></title>
        <description><![CDATA[Stories by Roberto Breve on Medium]]></description>
        <link>https://medium.com/@rbreve?source=rss-253d85b3134b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*7erJy7HlxcHgcaaOKfKFbQ.jpeg</url>
            <title>Stories by Roberto Breve on Medium</title>
            <link>https://medium.com/@rbreve?source=rss-253d85b3134b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 12:28:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rbreve/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[Displaying a List with SwiftUI from a remote JSON file]]></title>
            <link>https://medium.com/@rbreve/displaying-a-list-with-swiftui-from-a-remote-json-file-6b4e4280a076?source=rss-253d85b3134b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b4e4280a076</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Roberto Breve]]></dc:creator>
            <pubDate>Tue, 08 Oct 2019 13:42:34 GMT</pubDate>
            <atom:updated>2019-10-08T13:42:34.437Z</atom:updated>
            <content:encoded><![CDATA[<p>The purpose of this tutorial is to show a simple way to fetch data from a remote JSON file and display it on a List in SwiftUI. Apple has a <a href="https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation">tutorial</a> with a local file, also <a href="https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation">this one </a>teaches you how to do this, however I want to show a simpler way using a newer version of Xcode 11.0 (11A420a).</p><p>Apple beta libraries are getting constantly changed before releasing the final versions, so older tutorials might not work on the latest versions of XCode</p><p>Supposing we have this JSON file, that show an array of movie titles.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc199279fdef5b01e5651ddcefe25363/href">https://medium.com/media/dc199279fdef5b01e5651ddcefe25363/href</a></iframe><p>And we want to display them on a SwiftUI <a href="https://developer.apple.com/documentation/swiftui/list">List</a> like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*FDXEm9Aeso2R8AHkfjFUSg.png" /></figure><blockquote>First we need to define the model for Movie in this case a struct with Decodable and Identifiable protocols. <strong>Decodable</strong> to be able to decode it from the JSON file and <strong>Identifiable</strong> to be able to be listed with List. List allows you to display a list of data from an <strong>Identifiable</strong> Collection just like a UITableViewController.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a8acd3da09303ac8a8ff4bb2d0b3633/href">https://medium.com/media/5a8acd3da09303ac8a8ff4bb2d0b3633/href</a></iframe><p>CodingKeys basically maps the JSON key names with the variable name of the Model you created. In this case instead of <em>year</em> I named it <em>released</em> just for the purpose of showing that you can use your own names in the model as long as you define it in Coding Keys.</p><p>Next we create the fetcher class that will load the JSON file and decode it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/719b24099fe2fda883ae6a1ceb415ccb/href">https://medium.com/media/719b24099fe2fda883ae6a1ceb415ccb/href</a></iframe><p>Before understanding what is happening, we need to understand the new Combine framework.</p><p><em>The Combine framework provides a declarative Swift API for processing values over time. These values can represent many kinds of asynchronous events. Combine declares publishers to expose values that can change over time, and subscribers to receive those values from the publishers.</em></p><p><a href="https://developer.apple.com/documentation/combine/observableobject"><strong>ObervableObject</strong></a>: A type of object with a publisher that emits before the object has changed. By default an ObservableObject synthesizes an <a href="https://developer.apple.com/documentation/combine/observableobject/3362556-objectwillchange">objectWillChange</a> publisher that emits the changed value before any of its @Published properties changes.</p><p>@<strong>Published</strong> wraps the <strong>movies</strong> array and will generate events whenever it is changed.</p><p>The load() method fetches the JSON data from the network asynchronously, once the data has been loaded we assign it to <strong>movies. </strong>When <strong>movies</strong> changes it will send an event a subscriber.</p><p>This is the SwiftUI view, a List with the ObservedObject fetcher as parameter. Whenever movies is updated, the list will update autmatically.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38540a14f74b844afb12595925be081c/href">https://medium.com/media/38540a14f74b844afb12595925be081c/href</a></iframe><p>The whole code is here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea64d4db8daa2eaeebec17f5be761e5c/href">https://medium.com/media/ea64d4db8daa2eaeebec17f5be761e5c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2f26b3c5e7a865a3dd12568fd8abdd7/href">https://medium.com/media/d2f26b3c5e7a865a3dd12568fd8abdd7/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b4e4280a076" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tap gesture recognizer for object in SceneKit / ARKit]]></title>
            <link>https://medium.com/@rbreve/tap-gesture-recognizer-for-object-in-scenekit-arkit-dc9815f8643b?source=rss-253d85b3134b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc9815f8643b</guid>
            <category><![CDATA[swift-3]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[arkit]]></category>
            <dc:creator><![CDATA[Roberto Breve]]></dc:creator>
            <pubDate>Thu, 28 Sep 2017 22:29:01 GMT</pubDate>
            <atom:updated>2017-09-28T22:30:44.603Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been playing around with ARKit lately, tapping and object on the scene is very useful when interacting with objects, this snippet will add a tap recognizer to the SceneView and you will be able to access the SCNNode you tap over.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55eafaef182828e19d9b3cf83641ac20/href">https://medium.com/media/55eafaef182828e19d9b3cf83641ac20/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc9815f8643b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add Gesture Recognizer Swift]]></title>
            <link>https://medium.com/@rbreve/add-gesture-recognizer-swift-37b004a0a3e8?source=rss-253d85b3134b------2</link>
            <guid isPermaLink="false">https://medium.com/p/37b004a0a3e8</guid>
            <category><![CDATA[swift-3]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Roberto Breve]]></dc:creator>
            <pubDate>Mon, 17 Jul 2017 06:10:34 GMT</pubDate>
            <atom:updated>2017-07-17T06:18:06.353Z</atom:updated>
            <content:encoded><![CDATA[<p>Adds a tap gesture recognizer to a view</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99970a0b8268ee468107bcaec7f5fb21/href">https://medium.com/media/99970a0b8268ee468107bcaec7f5fb21/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37b004a0a3e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>