<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Ada’s Substack]]></title><description><![CDATA[App development for beginners]]></description><link>https://ruwaydah.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!5LuV!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fruwaydah.substack.com%2Fimg%2Fsubstack.png</url><title>Ada’s Substack</title><link>https://ruwaydah.substack.com</link></image><generator>Substack</generator><lastBuildDate>Fri, 22 May 2026 15:37:39 GMT</lastBuildDate><atom:link href="https://ruwaydah.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Ruwaydah]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[ruwaydah@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[ruwaydah@substack.com]]></itunes:email><itunes:name><![CDATA[Ada]]></itunes:name></itunes:owner><itunes:author><![CDATA[Ada]]></itunes:author><googleplay:owner><![CDATA[ruwaydah@substack.com]]></googleplay:owner><googleplay:email><![CDATA[ruwaydah@substack.com]]></googleplay:email><googleplay:author><![CDATA[Ada]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Splash Screen]]></title><description><![CDATA[Launch screen using storyboard and programmatically]]></description><link>https://ruwaydah.substack.com/p/splash-screen</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/splash-screen</guid><pubDate>Fri, 22 Sep 2023 11:31:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Creating Launch screen through storyboard</h2><ol><li><p>Choose launch screen template</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IpNE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IpNE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 424w, https://substackcdn.com/image/fetch/$s_!IpNE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 848w, https://substackcdn.com/image/fetch/$s_!IpNE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 1272w, https://substackcdn.com/image/fetch/$s_!IpNE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IpNE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png" width="1456" height="1036" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ebab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1036,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:272352,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IpNE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 424w, https://substackcdn.com/image/fetch/$s_!IpNE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 848w, https://substackcdn.com/image/fetch/$s_!IpNE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 1272w, https://substackcdn.com/image/fetch/$s_!IpNE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febab8a80-b2ef-41ea-9ab7-f8cc5da06752_1484x1056.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p></li><li><p>If launch screen contains image, then</p><ol><li><p>In assets.xcassets, load desired icons</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2l7k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2l7k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 424w, https://substackcdn.com/image/fetch/$s_!2l7k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 848w, https://substackcdn.com/image/fetch/$s_!2l7k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 1272w, https://substackcdn.com/image/fetch/$s_!2l7k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2l7k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png" width="1456" height="1017" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1017,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:415543,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2l7k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 424w, https://substackcdn.com/image/fetch/$s_!2l7k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 848w, https://substackcdn.com/image/fetch/$s_!2l7k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 1272w, https://substackcdn.com/image/fetch/$s_!2l7k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd224bf6c-ac06-4dc0-b294-dfd5b54481a8_2104x1470.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li></ol></li><li><p>Use provided views to build up the screen</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gkPd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gkPd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 424w, https://substackcdn.com/image/fetch/$s_!gkPd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 848w, https://substackcdn.com/image/fetch/$s_!gkPd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 1272w, https://substackcdn.com/image/fetch/$s_!gkPd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gkPd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png" width="1456" height="979" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:979,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:464666,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gkPd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 424w, https://substackcdn.com/image/fetch/$s_!gkPd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 848w, https://substackcdn.com/image/fetch/$s_!gkPd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 1272w, https://substackcdn.com/image/fetch/$s_!gkPd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a4cb6b-6ada-45a1-8880-2b2dfb4be738_2160x1452.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p></li><li><p>Go to app targets &#8594; App Icons and Launch Screen</p><ol><li><p>Select the storyboard file name</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Cwf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Cwf0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 424w, https://substackcdn.com/image/fetch/$s_!Cwf0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 848w, https://substackcdn.com/image/fetch/$s_!Cwf0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 1272w, https://substackcdn.com/image/fetch/$s_!Cwf0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Cwf0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png" width="1456" height="1078" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1078,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:223437,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Cwf0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 424w, https://substackcdn.com/image/fetch/$s_!Cwf0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 848w, https://substackcdn.com/image/fetch/$s_!Cwf0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 1272w, https://substackcdn.com/image/fetch/$s_!Cwf0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06ef6437-9fb2-4ecd-964c-ce97c892393d_1740x1288.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li></ol><h2>Creating Launch screen programmatically</h2><p>1. New SwiftUI View template</p><p>2. In the new file</p><pre><code>struct LaunchScreen: View {
    @State private var isActive = false
    var body: some View {
        ZStack {
            if isActive {
                ContentView()
            } else {
                VStack(alignment: .center) {
                    Text("Shopping App")
                        .font(.title)
                        .bold()
                    Image("Bag")
                }
            }
        }
        .onAppear {
            DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
                self.isActive = true
            }
        }
    }
}</code></pre><p>3. In main file</p></li></ol><pre><code>import SwiftUI

@main
struct LaunchScreenDemo: App {
    var body: some Scene {
        WindowGroup {
            LaunchScreen()
        }
    }
}</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FSPc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FSPc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 424w, https://substackcdn.com/image/fetch/$s_!FSPc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 848w, https://substackcdn.com/image/fetch/$s_!FSPc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!FSPc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FSPc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png" width="354" height="760.0255591054313" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1344,&quot;width&quot;:626,&quot;resizeWidth&quot;:354,&quot;bytes&quot;:66469,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FSPc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 424w, https://substackcdn.com/image/fetch/$s_!FSPc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 848w, https://substackcdn.com/image/fetch/$s_!FSPc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!FSPc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae7596b0-bdc1-4479-90b3-e887c3da6acd_626x1344.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ol start="3"><li><p>Launch screen with animation</p></li></ol><pre><code>struct LaunchScreen: View {
       // Initial position above the screen
    @State private var firstImageOffset: CGFloat = -100 
       // Initial position below the screen
    @State private var secondImageOffset: CGFloat = UIScreen.main.bounds.height
    @State private var showThirdImage = false
    @State private var isActive = false
    
    var body: some View {
        ZStack {
            if isActive == true {
                ContentView()
            } else {
                GeometryReader { geometry in
                    ZStack {
                        Image("ImageFromAbove")
                            .resizable()
                            .frame(width: 210, height: 260)
                            .offset(x: geometry.size.width/2 - 100, y: firstImageOffset)
                            .onAppear {
                                withAnimation(Animation.easeInOut(duration: 2)) {
                                    firstImageOffset = geometry.size.height / 2 - 100 // Center of the screen
                                }
                            }
                        Image("ImageFromBelow")
                            .resizable()
                            .frame(width: 210, height: 260)
                            .offset(x: geometry.size.width/2 - 100, y: secondImageOffset)
                            .onAppear {
                                withAnimation(Animation.easeInOut(duration: 2)) {
                                    secondImageOffset = geometry.size.height / 2 - 100 // Center of the screen
                                    DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
                                        showThirdImage = true
                                    }
                                }
                            }
// Sometimes this is not necessarry, it all depends how the two images above are colliding
                        if showThirdImage {
                            Image("FinalImage")
                                .resizable()
                                .frame(width: 200, height: 200)
                                .offset(x: geometry.size.width/2 - 100, y: geometry.size.height / 2 - 100)
                        }
                    }
                }
            }
        }
        .onAppear {
            DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
                self.isActive = true
            }
        }
    }
}</code></pre><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;b936296e-f8ad-42ff-a10a-f73a0338e638&quot;,&quot;duration&quot;:null}"></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Collapsible list ]]></title><description><![CDATA[Collapsible list in SwiftUI]]></description><link>https://ruwaydah.substack.com/p/collapsible-list</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/collapsible-list</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Tue, 19 Sep 2023 18:52:12 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>No. 1 and 2 work only and only if the list is in a <strong>NavigationView</strong></p><ol><li><p>Using <strong>VStack</strong></p></li></ol><pre><code><code>struct CollapsibleListView: View {
    let fastCars = ["Lamborghini Aventador","Bugatti Veyron","Porsche    
                   911 GT3","Ferrari 488 Pista" ,"McLaren 720S"]
    let electricCars = ["Tesla Model S","Nissan Leaf","BMW 
                       i3","Chevrolet Bolt EV","Audi e-tron"]
    var body: some View {
        NavigationView {
            VStack {
                List {
                    Section(header: Text("Fast cars")) {
                        ForEach(fastCars, id: \\.self) { car in
                            Text(car)
                        }
                    }
                    
                    Section(header: Text("Electric cars")) {
                        ForEach(electricCars, id: \\.self) { electric in
                            Text(electric)
                        }
                    }
                }
            }
         }
    }
}
</code></code></pre><ol start="2"><li><p>Using <strong>listStyle</strong></p></li></ol><pre><code><code>struct CollapsibleListView: View {
    let fastCars = ["Lamborghini Aventador","Bugatti Veyron","Porsche    
                   911 GT3","Ferrari 488 Pista" ,"McLaren 720S"]
    let electricCars = ["Tesla Model S","Nissan Leaf","BMW 
                       i3","Chevrolet Bolt EV","Audi e-tron"]
    var body: some View {
        NavigationView {
                List {
                    Section(header: Text("Fast cars")) {
                        ForEach(fastCars, id: \\.self) { car in
                            Text(car)
                        }
                    }
                    
                    Section(header: Text("Electric cars")) {
                        ForEach(electricCars, id: \\.self) { electric in
                            Text(electric)
                        }
                    }
                }
                .listStyle(.sidebar)
         }
    }
}</code></code></pre><ol start="3"><li><p><strong>Custom</strong> - not practical for many sections</p><pre><code>struct SectionHeaderView: View {
    var headerText: String
    @Binding var showList: Bool
    var body: some View {
        HStack {
            Text(headerText)
                .font(.caption)
                .foregroundColor(.gray)
            Spacer()
            Image(systemName: showList ? "chevron.down" :  
                   "chevron.right")
                .foregroundColor(.blue)
                .onTapGesture {
                    showList.toggle()
                }
        }
    }
}

struct CollapsibleListView: View {
    @State private var showFirstList: Bool = false
    @State private var showSecondList: Bool = false
    let fastCars = ["Lamborghini Aventador","Bugatti Veyron","Porsche    
                   911 GT3","Ferrari 488 Pista" ,"McLaren 720S"]
    let electricCars = ["Tesla Model S","Nissan Leaf","BMW 
                       i3","Chevrolet Bolt EV","Audi e-tron"]
    var body: some View {
        List {
            Section(header: 
                      SectionHeaderView(headerText: "Fast  
                          cars",showList: $showFirstList)
            ){
                if showFirstList {
                    ForEach(fastCars, id: \.self) { car in
                        Text(car)
                    }
                }
            }

            Section(header: 
                     SectionHeaderView(headerText: "Electric 
                         cars",showList:$showSecondList)
            ){
                if showSecondList {
                    ForEach(electricCars, id: \.self) { electric in
                        Text(electric)
                    }
                }
            }
        }
    }
}</code></pre></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!56Zv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!56Zv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 424w, https://substackcdn.com/image/fetch/$s_!56Zv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 848w, https://substackcdn.com/image/fetch/$s_!56Zv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 1272w, https://substackcdn.com/image/fetch/$s_!56Zv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!56Zv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png" width="430" height="864.6071428571429" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1126,&quot;width&quot;:560,&quot;resizeWidth&quot;:430,&quot;bytes&quot;:173695,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!56Zv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 424w, https://substackcdn.com/image/fetch/$s_!56Zv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 848w, https://substackcdn.com/image/fetch/$s_!56Zv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 1272w, https://substackcdn.com/image/fetch/$s_!56Zv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573c16ff-a9cf-4790-a229-470324c66bbf_560x1126.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hM15!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hM15!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 424w, https://substackcdn.com/image/fetch/$s_!hM15!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 848w, https://substackcdn.com/image/fetch/$s_!hM15!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 1272w, https://substackcdn.com/image/fetch/$s_!hM15!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hM15!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png" width="426" height="869.04" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1122,&quot;width&quot;:550,&quot;resizeWidth&quot;:426,&quot;bytes&quot;:140221,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hM15!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 424w, https://substackcdn.com/image/fetch/$s_!hM15!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 848w, https://substackcdn.com/image/fetch/$s_!hM15!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 1272w, https://substackcdn.com/image/fetch/$s_!hM15!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7f674db-c3ac-4497-bbab-b564ae1011f0_550x1122.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Alamofire & Swift]]></title><description><![CDATA[Using alamofire library]]></description><link>https://ruwaydah.substack.com/p/alamofire-and-swift</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/alamofire-and-swift</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Thu, 04 May 2023 20:47:42 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/d79dd6a5-5f81-4732-8993-27873557fe06_921x649.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2><strong>What is Alamofire?</strong></h2><p>Alamofire is an open-source networking library written in Swift that simplifies the process of sending HTTP requests and handling responses. It supports various HTTP methods and includes additional features like parameter encoding and response validation. </p><h2>How to use Alamofire in an app?</h2><p>To use Alamofire in an app, follow these general steps:</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><ol><li><p>Add Alamofire as a dependency to your project using CocoaPods or Swift Package Manager.</p></li><li><p>Import the Alamofire module into your project.</p></li><li><p>Use the provided API to make requests to an API and handle the responses.</p></li></ol><p>Here is an example code snippet that shows how to use Alamofire to make a GET request:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!i-2m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!i-2m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 424w, https://substackcdn.com/image/fetch/$s_!i-2m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 848w, https://substackcdn.com/image/fetch/$s_!i-2m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!i-2m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!i-2m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg" width="1456" height="657" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:657,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:84656,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!i-2m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 424w, https://substackcdn.com/image/fetch/$s_!i-2m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 848w, https://substackcdn.com/image/fetch/$s_!i-2m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!i-2m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0babec5-1c64-43f4-a566-2fad53d0c8b0_1500x677.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In this example, <strong>AF.request </strong>creates a request to the specified URL, and the <strong>response</strong> method sets a closure to handle the response. The function then print the response to the console.</p><p>The request can be customised by setting parameters, headers, and encoding types, among other things. The response object can also be used to handle any errors or parse the returned data.</p><h3>Adding Alamofire as a dependency</h3><ol><li><p><strong>Using CocoaPods</strong></p></li></ol><p>Installing Alamofire using terminal.</p><ul><li><p>Navigate to project folder</p></li></ul><pre><code><code>cd ProjectName
</code></code></pre><ul><li><p>Create pod file</p></li></ul><pre><code><code>Pod init
</code></code></pre><ul><li><p>Open the podfile created and add the line [version number is optional]</p></li></ul><pre><code><code>pod "Alamofire", "[version number]"
</code></code></pre><ul><li><p>Save file and run the following command which will create Pods folders in the project</p></li></ul><pre><code><code>pod install
</code></code></pre><ul><li><p>Now open the project&#8217;s workspace**[projectname.xcworkspace**] instead of project folder [<strong>projectname</strong>.<strong>xcodeproj</strong>]</p><p></p><ol start="2"><li><p><strong>Using SPM</strong></p></li></ol></li></ul><ul><li><p>Go to projectName &#8594; Package Dependencies &#8594; click on +</p></li><li><p>Copy and paste the following url</p></li></ul><pre><code><code>&lt;https://github.com/Alamofire/Alamofire.git&gt;
</code></code></pre><ul><li><p>Set Version to Up to Next Major (or what works for you!) and click Next</p></li></ul><p><strong>Note</strong>: Package may take some minutes to verify and load.</p><p><strong>Or</strong></p><p>Create a .swift file named&nbsp;<code>Package</code>&nbsp;in the project root folder and add the dependencies as below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GP0y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GP0y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 424w, https://substackcdn.com/image/fetch/$s_!GP0y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 848w, https://substackcdn.com/image/fetch/$s_!GP0y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!GP0y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GP0y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg" width="1456" height="557" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:557,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:78747,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GP0y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 424w, https://substackcdn.com/image/fetch/$s_!GP0y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 848w, https://substackcdn.com/image/fetch/$s_!GP0y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!GP0y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8e79e8c-0ce4-47b3-8835-9780c4581e31_1500x574.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>then run the command below in the root folder directory</p><pre><code>swift build</code></pre><h2><strong>A simple fetch example:</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zf3W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zf3W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 424w, https://substackcdn.com/image/fetch/$s_!zf3W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 848w, https://substackcdn.com/image/fetch/$s_!zf3W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!zf3W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zf3W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg" width="1066" height="1499" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1499,&quot;width&quot;:1066,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:209729,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zf3W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 424w, https://substackcdn.com/image/fetch/$s_!zf3W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 848w, https://substackcdn.com/image/fetch/$s_!zf3W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!zf3W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03fa7395-b23a-4161-82af-9782671358f8_1066x1499.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In this example, we create a URL string and define some parameters and headers. We then use the <code>AF.request()</code> method to make a GET request to the URL, passing in the HTTP method, parameters, encoding type, and headers. We also validate the response status code to ensure that it falls within the range of 200 to 299.</p><p>Finally, we use a switch statement to handle the response, printing out the value of the response in case of success and the error message in case of failure.<code>
</code></p><p><em><strong>Note</strong></em>: To be able to send requests to server</p><p>Go to AppName &#8594; Targets &#8594; Signing + Capabilities</p><p>Tick Outgoing Connections (Client)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7ZnG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7ZnG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 424w, https://substackcdn.com/image/fetch/$s_!7ZnG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 848w, https://substackcdn.com/image/fetch/$s_!7ZnG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 1272w, https://substackcdn.com/image/fetch/$s_!7ZnG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7ZnG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png" width="775" height="348" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca216026-346e-41b3-8b64-c5da50b61f94_775x348.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:348,&quot;width&quot;:775,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:41415,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7ZnG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 424w, https://substackcdn.com/image/fetch/$s_!7ZnG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 848w, https://substackcdn.com/image/fetch/$s_!7ZnG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 1272w, https://substackcdn.com/image/fetch/$s_!7ZnG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca216026-346e-41b3-8b64-c5da50b61f94_775x348.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Higher Order Functions in Swift]]></title><description><![CDATA[Filter, map, reduce, compactMap, flatMap and combinations]]></description><link>https://ruwaydah.substack.com/p/higher-order-functions-in-swift</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/higher-order-functions-in-swift</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Mon, 17 Apr 2023 20:33:06 GMT</pubDate><content:encoded><![CDATA[<p>Higher-order functions are functions that take one or more functions as arguments, and/or return a function as their result. These functions allow you to write concise and expressive code that is easy to read and maintain.</p><p>Note: </p><p>    $0 &#8594; placeholder for each item in an array</p><p>    $1 &#8594; placeholder for next item in the iteration</p><ol><li><p><strong>map</strong>: This function applies a given transformation to each element of a collection and returns a new collection of the transformed elements.</p><p></p><p>a. Using &#8216;map&#8217; to get specific properties</p><pre><code>struct Cookie {
&#9;let name: String
&#9;let price: Double
&#9;let quanity: Int
}

let order = [
&#9;Cookie(name: "Blueberry", price: 30.00, quantity: 2),
&#9;Cookie(name: "Chocolate", price: 40.95, quantity: 3)
]

let cookieNames = orders.map { $0.name }
print(cookieNames)

// ["blueberry", "Chocolate", "original", "raisins"]</code></pre><p>b. Using &#8216;map&#8217; to perform a transformation &#8594; Performing certain operations on the data so that its no longer equal to the original. E.g let&#8217;s remove the 2% vat from all prices</p><pre><code>let excludedVat = orders.map { $0.price * 0.98 }
print(excludedVat)
// [29.4, 40.131, 10.731, 5.684]</code></pre></li><li><p><strong>filter</strong>: This function returns a new collection that contains only the elements of the original collection that satisfy a given condition &#8594; { $0.condition }</p><pre><code>let goodCookie = order.filter { $0.name == "Chocolate"}
print(goodCookie)

 // [Cookie(name: "Chocolate", price: 40.95, quantity: 6)]

let bestCookies = order.filter {$0.quantity &gt; 3 }
print(bestCookies)

// [Cookie(name: "Chocolate", price: 40.95, quantity: 6),
//  Cookie(name: "original", price: 10.95, quantity: 10)]</code></pre></li><li><p><strong>reduce</strong>: This function combines all elements of a collection into a single value, by applying a given operation to each element in turn.</p><p>.reduce takes two parameters (initial value, operation)</p><pre><code>let prices = [29.4, 40.131, 10.731, 5.684]

let totalPrice = prices.reduce(0, +)
print(totalPrice)
// 85.946

let totalQuantity = orders.reduce(0, {$0 + $1.quantity})
print(totalQuantity)

// 19
</code></pre><p>For totalPrice we are doing a simple summation where the initial value is 0 and we are just adding the data of prices.</p><p>For totalQuantity we are adding only &#8220;quantity&#8221; for each item so basically 2 + 6&#8230;</p><p></p></li><li><p><strong>flatMap</strong>: This function applies a given transformation to each element of a collection and returns a new collection that is the flattened result of the transformations.</p><pre><code>let arrays = [
&#9;["Penguin", "Duck", "Chicken"],
&#9;["Lion", "Leopard", "Tiger"],
&#9;["Crocodile", "Snakes", "Snails"]
]

let animals = arrays.flatMap {$0}
print(arrays)
// [["Penguin", "Duck", "Chicken"], ["Lion", "Leopard", "Tiger"], ["Crocodile", "Snakes", "Snails"]]

print(animals)
// ["Penguin", "Duck", "Chicken", "Lion", "Leopard", "Tiger", "Crocodile", "Snakes", "Snails"]</code></pre></li><li><p><strong>CompactMap: </strong>This function applies transformation to an array and returns a new collection of array of non-nil.</p><pre><code>let nils = ["Apple","oranges", nil, "Strawberry", nil, nil, "Grapes"]
let nonNils = nils.compactMap { $0 }
print(nonNils)

// ["Apple", "oranges", "Strawberry", "Grapes"]</code></pre></li><li><p><strong>Combinations: </strong>combining high order functions</p><p>a. Taking the struct of Cookie as example to combine &#8220;map&#8221; and &#8220;reduce&#8221;</p><pre><code>let totalSales = orders.map { $0.price * Double($0.quantity)}.reduce(0, +)

//Total sales: 421.00000000000006</code></pre></li></ol><p>      We first get sales per order by performing a map where we are multiplying the   price of each item by their respective quantity. The quantity is formatted to double cause price is double, so results will be in double.</p><p>     We then get total sales by adding each sales per order. To achieve this we do a reduce with operator +.</p><p>      b. Taking the array of animals as example to combine &#8220;flatMap&#8221; and &#8220;filter&#8221;</p><pre><code>let arrays = [["Penguin", "Duck", "Chicken"],["Lion", "Leopard", "Tiger"],["Crocodile", "Snakes", "Snails"]]

let animals = arrays.flatMap {$0.filter { $0.hasPrefix("C")}}
print(animals)
//["Chicken", "Crocodile"]  </code></pre><p>               </p>]]></content:encoded></item><item><title><![CDATA[Using Date in SwiftUI]]></title><description><![CDATA[Exploring date and time manipulation in SwiftUI.]]></description><link>https://ruwaydah.substack.com/p/using-date-in-swiftui</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/using-date-in-swiftui</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Sun, 16 Apr 2023 19:09:33 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Date formatting</h2><p>Step 1: get the date from Date()</p><p>Step 2: Format the date using .formatted()</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Date can be styled as : .<strong>complete</strong>, .<strong>abbreviated</strong>, .<strong>long</strong>, .<strong>numeric</strong> and .<strong>omitted</strong> (for no display).</p><p>Time can be styled as: .<strong>complete</strong>, .<strong>standard</strong>, .<strong>omitted</strong>, .<strong>shortened.</strong></p><pre><code>@state var dateCreated: Date()

dateCreated.formatted() // Jan 21, 2022, 4:03 PM
dateCreated.formatted(date: .complete, time: .omitted) // Sunday, 
January 22, 2023
dateCreated.formatted(date: .omitted, time: .complete) // 4:03:12 PM CST
dateCreated.formatted(date: .long, time: .shortened) // January 22, 2019, 4:03 PM
dateCreated.formatted(date: .abbreviated, time: .standard) // January 22, 2019, 4:03:12 PM
dateCreated.formatted(date: .numeric, time: .complete) // 1/22/2023, 4:03:12 PM CST</code></pre><h3>Getting specific time period of a date</h3><pre><code>Text("Week of the year: " + Date().formatted(.dateTime.week()))
Text("Week of the month: " +  Date().formatted(.dateTime.week(.weekOfMonth)))
Text("Weekday: " + Date().formatted(.dateTime.weekday()))
Text("Current year" + Date().formatted(.dateTime.year()))</code></pre><h2>Using DatePicker component</h2><p>DatePicker provide a view of a calendar and optionally a time. This view is bound to a date instance (Date()).</p><p>The DatePicker takes two parameters:</p><ol><li><p>A text, usually the title for the calendar</p></li><li><p>The @State value bound to the date instance</p></li></ol><pre><code>DatePicker("Title", selection: $variable)</code></pre><p>Example: </p><pre><code>@State private var dateTime = Date()
DatePicker("Enter your birthday", selection: $dateTime</code></pre><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WVVo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WVVo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 424w, https://substackcdn.com/image/fetch/$s_!WVVo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 848w, https://substackcdn.com/image/fetch/$s_!WVVo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 1272w, https://substackcdn.com/image/fetch/$s_!WVVo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WVVo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png" width="389" height="167" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:167,&quot;width&quot;:389,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:21456,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WVVo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 424w, https://substackcdn.com/image/fetch/$s_!WVVo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 848w, https://substackcdn.com/image/fetch/$s_!WVVo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 1272w, https://substackcdn.com/image/fetch/$s_!WVVo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca8e3b9-0c2a-4de8-8280-314c9a5615e2_389x167.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>DatePicker can also be written as:</p><pre><code>DatePicker(selection: $dateTime, in: ...Date(), displayedComponents: .date) { 
   Text("Select a date") 
}</code></pre><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iNiS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iNiS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 424w, https://substackcdn.com/image/fetch/$s_!iNiS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 848w, https://substackcdn.com/image/fetch/$s_!iNiS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 1272w, https://substackcdn.com/image/fetch/$s_!iNiS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iNiS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png" width="391" height="192" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c5694376-7161-4e64-a99d-065b84b67d31_391x192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:192,&quot;width&quot;:391,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:19930,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iNiS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 424w, https://substackcdn.com/image/fetch/$s_!iNiS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 848w, https://substackcdn.com/image/fetch/$s_!iNiS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 1272w, https://substackcdn.com/image/fetch/$s_!iNiS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5694376-7161-4e64-a99d-065b84b67d31_391x192.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p>This takes as parameter:</p><ol><li><p>selection: a state value bound to Date()</p></li><li><p>in:</p><ol><li><p>&#8230;Date() : choose a date up to now</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6RsR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6RsR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 424w, https://substackcdn.com/image/fetch/$s_!6RsR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 848w, https://substackcdn.com/image/fetch/$s_!6RsR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 1272w, https://substackcdn.com/image/fetch/$s_!6RsR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6RsR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png" width="382" height="389" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:389,&quot;width&quot;:382,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:77104,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6RsR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 424w, https://substackcdn.com/image/fetch/$s_!6RsR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 848w, https://substackcdn.com/image/fetch/$s_!6RsR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 1272w, https://substackcdn.com/image/fetch/$s_!6RsR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cae5949-a566-45d1-aadb-1c845cf7dae9_382x389.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li><li><p>Date()&#8230; : choose a date from now onwards</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aEmT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aEmT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 424w, https://substackcdn.com/image/fetch/$s_!aEmT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 848w, https://substackcdn.com/image/fetch/$s_!aEmT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 1272w, https://substackcdn.com/image/fetch/$s_!aEmT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aEmT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png" width="383" height="376" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:376,&quot;width&quot;:383,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:72876,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aEmT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 424w, https://substackcdn.com/image/fetch/$s_!aEmT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 848w, https://substackcdn.com/image/fetch/$s_!aEmT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 1272w, https://substackcdn.com/image/fetch/$s_!aEmT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12b82d3a-5197-4d4a-afc0-931bf79d7969_383x376.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li><li><p>displayedComponents: takes either date or hours and mins</p><ol><li><p>.date</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!u7qD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!u7qD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 424w, https://substackcdn.com/image/fetch/$s_!u7qD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 848w, https://substackcdn.com/image/fetch/$s_!u7qD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 1272w, https://substackcdn.com/image/fetch/$s_!u7qD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!u7qD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png" width="388" height="41" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:41,&quot;width&quot;:388,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:15898,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!u7qD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 424w, https://substackcdn.com/image/fetch/$s_!u7qD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 848w, https://substackcdn.com/image/fetch/$s_!u7qD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 1272w, https://substackcdn.com/image/fetch/$s_!u7qD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28372e3b-a9d4-4a52-92ac-7ed41d0fa81d_388x41.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>.hourAndMinute</p></li></ol></li></ol><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7VSF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7VSF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 424w, https://substackcdn.com/image/fetch/$s_!7VSF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 848w, https://substackcdn.com/image/fetch/$s_!7VSF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 1272w, https://substackcdn.com/image/fetch/$s_!7VSF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7VSF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png" width="392" height="55" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:55,&quot;width&quot;:392,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:11736,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7VSF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 424w, https://substackcdn.com/image/fetch/$s_!7VSF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 848w, https://substackcdn.com/image/fetch/$s_!7VSF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 1272w, https://substackcdn.com/image/fetch/$s_!7VSF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f943ae4-dc33-4288-bcd1-583a3fbea255_392x55.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3>Styling date picker</h3><ol><li><p>GraphicalDatePickerStyle(): displays an interactive calendar or clock.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Vmnp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Vmnp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 424w, https://substackcdn.com/image/fetch/$s_!Vmnp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 848w, https://substackcdn.com/image/fetch/$s_!Vmnp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 1272w, https://substackcdn.com/image/fetch/$s_!Vmnp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Vmnp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png" width="294" height="374" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:374,&quot;width&quot;:294,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:30212,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Vmnp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 424w, https://substackcdn.com/image/fetch/$s_!Vmnp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 848w, https://substackcdn.com/image/fetch/$s_!Vmnp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 1272w, https://substackcdn.com/image/fetch/$s_!Vmnp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe3d22e8-6cf2-4746-a06c-71ee9639b30c_294x374.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li><li><p>CompactDatePickerStyle(): displays the components in a compact, textual format</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Os8Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Os8Q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 424w, https://substackcdn.com/image/fetch/$s_!Os8Q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 848w, https://substackcdn.com/image/fetch/$s_!Os8Q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 1272w, https://substackcdn.com/image/fetch/$s_!Os8Q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Os8Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png" width="303" height="85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:303,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:12266,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Os8Q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 424w, https://substackcdn.com/image/fetch/$s_!Os8Q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 848w, https://substackcdn.com/image/fetch/$s_!Os8Q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 1272w, https://substackcdn.com/image/fetch/$s_!Os8Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8aad3a-d585-4948-bf20-81403b30d228_303x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>FieldDatePickerStyle(): displays the components in an editable field.</p></li><li><p>StepperDatePickerStyle(): displays the components in an editable field, with adjoining stepper that can increment/decrement the selected component.</p></li><li><p>WheelDatePickerStyle(): displays each component as columns in a scrollable wheel.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Okb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Okb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 424w, https://substackcdn.com/image/fetch/$s_!8Okb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 848w, https://substackcdn.com/image/fetch/$s_!8Okb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 1272w, https://substackcdn.com/image/fetch/$s_!8Okb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Okb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png" width="296" height="198" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:198,&quot;width&quot;:296,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:21952,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8Okb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 424w, https://substackcdn.com/image/fetch/$s_!8Okb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 848w, https://substackcdn.com/image/fetch/$s_!8Okb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 1272w, https://substackcdn.com/image/fetch/$s_!8Okb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311ed398-d3cc-4c6d-9d83-d5d2a55be90f_296x198.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h2>Getting specific date</h2><p>To get current date in the format "yyyy-MM-dd HH:mm:ss"</p><pre><code><code>let date = Date()
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd HH:mm:ss"
let formattedDate = format.string(from: date)
print(formattedDate)
</code></code></pre><p>To get current day, month, year: use Calendar class</p><pre><code><code>let calendar = Calendar.current
calendar.component(.year, from: date)
calendar.component(.month, from: date)
calendar.component(.day, from: date)
calendar.component(.weekday, from: date)</code></code></pre><p>All returns integer values, i.e, if the month is September .month would return 9, or It will return 1 when it is in Sunday as in Gregorian Calendar.</p><p><strong>Note:</strong> .<strong>current</strong> &nbsp;may give unexpected results if the device is set the a <em>different</em> calendar (like&nbsp;.hebrew). Use&nbsp;Calendar(identifier: .gregorian)</p><pre><code>let year = Calendar(identifier: .gregorian).dateComponents([.year], from: Date()).year

// iOS 15+
let year = Calendar(identifier: .gregorian).dateComponents([.year], from: .now).year</code></pre><h3>Returning a new date from a specific date</h3><pre><code>Calendar.current.date(byAdding: .day, value: 1, to: oldTime ?? Date())</code></pre><p>This method takes three parameters:</p><ul><li><p>the unit to add (in this case <code>.day</code>)</p></li><li><p>the value to add (in this case <code>1</code>, which means we are adding 1 day to the <code>oldTime</code>)</p></li><li><p>the starting date (in this case <code>oldTime ?? Date()</code>, which means if <code>oldTime</code> is <code>nil</code> use the current date and time)</p></li></ul><p>The method returns a new date representing the result of adding the specified value of the given unit to the given date.</p><h3>Get all months of the current year</h3><pre><code>func getMonths() -&gt; [String] {
   var months: [String] = []
   let currentYear = calendar.component(.year, from: Date())
&#9;&#9;
   for month in 1...12 {
&#9;let dateComponents = DateComponents(year: currentYear, month: month)
&#9;if let date = calendar.date(from: dateComponents) {
&#9;&#9;let monthFormatter = DateFormatter()
&#9;&#9;monthFormatter.dateFormat = "MMMM"
&#9;&#9;let monthName = monthFormatter.string(from: date)
&#9;&#9;months.append(monthName)
&#9;}//if
   }//for
&#9;return months
}//getMonths</code></pre><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Carousel animation in Swiftui]]></title><description><![CDATA[Building a Carousel View with Flip Animation in SwiftUI]]></description><link>https://ruwaydah.substack.com/p/carousel-animation-in-swiftui</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/carousel-animation-in-swiftui</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Sat, 08 Apr 2023 20:23:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Consider the dictionary below for our data: </p><pre><code>var details = [
"Tom": "https://m.media-amazon.com/images/W/IMAGERENDERING_521856-T1/images/I/81sGVvD67eL._SY450_.jpg",
"Beast":"https://ntvb.tmsimg.com/assets/p21948923_v_h10_aa.jpg?w=960&amp;h=540",
"Owl":"https://ih1.redbubble.net/image.2385686111.4230/poster,504x498,f8f8f8-pad,600x600,f8f8f8.jpg",
"Ducky":"https://eikhu9b6e94.exactdn.com/wp-content/uploads/2020/03/DuckTales-Poster.jpg?strip=all&amp;lossy=0&amp;quality=80&amp;webp=80&amp;avif=80&amp;ssl=1",
"Panda": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSGeOPlpwbIU82MVrzQL0vyS8u3Xvr17aPuiw&amp;usqp=CAU",&#9;"Dragon":"https://imgix.ranker.com/user_node_img/585/11694849/original/11694849-photo-u23?auto=format&amp;q=60&amp;fit=crop&amp;fm=pjpg&amp;dpr=2&amp;w=375"
]</code></pre><p>This dictionary includes a <em>key</em> representing the title and a corresponding <em>value</em> representing the URL of an image.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h4>Step 1: Create the card view</h4><pre><code>struct CardView: View {
&#9;var body: some View {
&#9;  Rectangle()
&#9;     .fill(Color.pink)&#9;
   &#9;     .frame(height:400)
&#9;     .cornerRadius(20)
&#9;     .padding()
&#9;     .shadow(color: .pink.opacity(0.5), radius: 2)
&#9;}
}</code></pre><h4>Step 2: Create the front view of the card</h4><pre><code>struct CardFrontView: View {
&#9;@State var image: String
&#9;@Binding var degree : Double
    var body: some View {
&#9;VStack {
&#9;   AsyncImage(url: URL(string: image)) { phase in
&#9;    if let image = phase.image {
&#9;      image
&#9;&#9;.resizable()
&#9;&#9;.aspectRatio(contentMode: .fill)
&#9;&#9;.frame(width: 350, height: 400)
&#9;    } else {&#9;&#9;&#9;&#9;
              Image(systemName: "photo")
&#9;&#9;.resizable()
&#9;&#9;.aspectRatio(contentMode: .fill)
&#9;&#9;.frame(width: 300, height: 300, alignment: .center)
            } 
&#9; }
&#9;   .cornerRadius(20)
&#9;}
&#9;.padding(20)
&#9;.rotation3DEffect(Angle(degrees: degree), axis:(x:0,y:1,z:0))
   }//body
}//CardFrontView</code></pre><h4>Step 3: Create the reverse view of the card</h4><pre><code>struct CardBackView: View {
&#9;@State var title: String
&#9;@Binding var degree : Double
    var body: some View {
&#9;VStack {
&#9;  Text(title)
&#9;    .font(.title)
&#9;  Text("A deeper view into \(title). \n What is it about? \n Genre: \n Duration: \n ratings: ")
&#9;    .font(.body)
&#9;    .multilineTextAlignment(.center)
&#9;}
&#9;.rotation3DEffect(Angle(degrees: degree), axis:(x:0,y:1,z:0))
&#9;.frame(width: 300, height: 300, alignment: .center)
   }//body
}//CardBackView</code></pre><p>The <em><strong>.rotation3DEffect</strong></em> modifier is used to rotate a view in 3D space along a specified axis. The <em><strong>degree</strong></em> parameter specifies the angle of rotation in degrees, while the <em><strong>axis</strong></em> parameter specifies the axis around which the view is to be rotated. In our case, we are rotating along the y axis.</p><h4>Step 4: Create the flip animation</h4><pre><code>@State var backDegree = 0.0
@State var frontDegree = -90.0
@State var isFlipped = false
let durationAndDelay : CGFloat = 0.3
func flipCard(){
    isFlipped = !isFlipped
    if isFlipped {
&#9;withAnimation(.linear(duration: durationAndDelay)) {
&#9;   backDegree = 90
        }     
        withAnimation(.linear(duration:durationAndDelay)
             .delay(durationAndDelay)) {
&#9;&#9;frontDegree = 0
&#9;}
    } else {&#9;&#9;&#9;
        withAnimation(.linear(duration: durationAndDelay)) {
&#9;&#9;frontDegree = -90
        }
        withAnimation(.linear(duration: durationAndDelay)
             .delay(durationAndDelay)){
&#9;&#9;backDegree = 0
&#9;}
    }
}//flipCard</code></pre><h4>Step 5: Stack both the front and back views together. </h4><p>The front and back view of the card are displayed in a ZStack</p><pre><code>struct FullCardView: View {
    @State var title: String
    @State var image: String
    var body: some View {
&#9;ZStack {
&#9;   CardFrontView(image: image, degree: $backDegree)
&#9;   CardBackView(title: title, degree: $frontDegree)
&#9;}
&#9;.shadow(color: .black, radius: 16)
&#9;.onTapGesture {
&#9;    flipCard()
&#9;}
    }//body
}//FullCardView</code></pre><h4>Step 6: Create the carousel view</h4><pre><code>struct ContentView: View {
    @State private var index = 0
     var body: some View {
       VStack {
&#9;TabView(selection: $index) {
&#9;   ForEach(details.sorted(by: &lt;), id: \.key) { key, value in
&#9;&#9;CardView()
&#9;&#9;   .overlay(FullCardView(title: key, image: value))
&#9;   }
&#9;    .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
       }
     }//body</code></pre><p>Here we create a <strong>TabView</strong> that displays a collection of cards. The <code>index</code> variable is a state variable that keeps track of the currently selected tab.</p><p>The <strong>TabView</strong> displays a set of <code>CardView</code> objects, each of which is overlaid with a <code>FullCardView</code> that shows the full details of the card. </p><p>The <em>details</em> dictionary contains the key-value pairs of the titles and image URLs for each card.</p><p>The ForEach loop iterates over the sorted key-value pairs of <em>details</em> and creates a <code>CardView</code> object for each card. </p><p>The <strong>tabViewStyle</strong> modifier sets the style of the <strong>TabView</strong> to <strong>PageTabViewStyle</strong>, which displays the cards in a <em>paged</em> manner and hides the tab bar. The <strong>indexDisplayMode</strong> is set to <code>.</code><strong>never</strong> to hide the index display of the <strong>TabView</strong>.</p><h2>How does the flipCard function work?</h2><p>The function has three variables named &#8220;backDegree&#8221;, &#8220;frontDegree&#8221;, and &#8220;isFlipped&#8221;. </p><p>When the function is called, it toggles the &#8220;isFlipped&#8221; variable and applies animation to change the &#8220;backDegree&#8221; and &#8220;frontDegree&#8221; values accordingly. </p><p>The back card&#8217;s angle starts at 0 and changes to 90, and the front of the card begins at -90 degrees and changes to 0. </p><p>To reverse the animation,  the values are changed back to their start values.</p><p>The front and back views of the card are rotated around the y-axis to create a flip animation. By using <code>.</code><em><strong>linear</strong></em>, the flip animation will be smooth and consistent without any abrupt changes (acceleration/deceleration) in speed. The <em><strong>delay</strong></em> modifier is used to delay the animation of the &#8220;frontDegree&#8221; variable by the same duration as the &#8220;backDegree&#8221;, so that the flip animation appears more realistic.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6ifs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6ifs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 424w, https://substackcdn.com/image/fetch/$s_!6ifs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 848w, https://substackcdn.com/image/fetch/$s_!6ifs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 1272w, https://substackcdn.com/image/fetch/$s_!6ifs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6ifs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png" width="315" height="616" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:616,&quot;width&quot;:315,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:191659,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6ifs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 424w, https://substackcdn.com/image/fetch/$s_!6ifs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 848w, https://substackcdn.com/image/fetch/$s_!6ifs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 1272w, https://substackcdn.com/image/fetch/$s_!6ifs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f50b0d8-10c6-4cce-a2da-66fb5b227a4f_315x616.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NfR3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NfR3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 424w, https://substackcdn.com/image/fetch/$s_!NfR3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 848w, https://substackcdn.com/image/fetch/$s_!NfR3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 1272w, https://substackcdn.com/image/fetch/$s_!NfR3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NfR3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png" width="310" height="618" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/adf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:618,&quot;width&quot;:310,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45287,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NfR3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 424w, https://substackcdn.com/image/fetch/$s_!NfR3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 848w, https://substackcdn.com/image/fetch/$s_!NfR3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 1272w, https://substackcdn.com/image/fetch/$s_!NfR3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadf4e972-3b07-4de4-82af-8c38ebf892ea_310x618.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!y2gw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!y2gw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 424w, https://substackcdn.com/image/fetch/$s_!y2gw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 848w, https://substackcdn.com/image/fetch/$s_!y2gw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 1272w, https://substackcdn.com/image/fetch/$s_!y2gw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!y2gw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png" width="323" height="625" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:625,&quot;width&quot;:323,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:211814,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!y2gw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 424w, https://substackcdn.com/image/fetch/$s_!y2gw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 848w, https://substackcdn.com/image/fetch/$s_!y2gw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 1272w, https://substackcdn.com/image/fetch/$s_!y2gw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a973c5a-a585-474b-adaa-fff7d405b9a6_323x625.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Synchronous v/s Asynchronous API call in Swift]]></title><description><![CDATA[Difference between a synchronous call and an asynchronous one.]]></description><link>https://ruwaydah.substack.com/p/synchronous-vs-asynchronous-api-call</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/synchronous-vs-asynchronous-api-call</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Wed, 15 Mar 2023 10:18:53 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/e38f8905-b852-4569-9e63-85803551fefd_284x227.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Swift, the main difference between a synchronous API call and an asynchronous one is how you handle the response data.</p><h2>Synchronous call</h2><p>With a synchronous API call, the app freezes while the call is being made. The app remain unresponsive until a response is available.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Here is an example  using the <code>URLSession</code>:</p><pre><code>let url = URL(string: "https://www.boredapi.com/api/activity")!
let request = URLRequest(url: url)

do {
    let data = try URLSession.shared.data(request: request)
    let activity = try JSONDecoder().decode(Activity.self, from: data)
    self.activities = activity
} catch {
    print("Error decoding data")
}</code></pre><h2>Asynchronous call</h2><p>With an asynchronous API call, the app remain responsive while the API call is being made.</p><p>Here is an example using the <code>URLSession</code>:</p><pre><code>let url = URL(string: "https://www.boredapi.com/api/activity")!
let request = URLRequest(url: url)

URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
&#9;print("Error fetching data: \(error)")        
&#9;return
    }

    guard let data = data else {
        print("No data")
        return
    }

    do {
      let activity = try JSONDecoder().decode(Activity.self, from: data)
      DispatchQueue.main.async {
&#9;self.activities = activity
      }
    } catch {
        print("Error decoding data: \(error)")
    }
}.resume()</code></pre><p>As can be noted, the asynchronous API call uses a closure that gets called when the response comes back. This closure allows you to handle the response data without blocking the main thread of your app.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Getting started with Unit Testing in SwiftUI]]></title><description><![CDATA[A simple test case of Unit Testing]]></description><link>https://ruwaydah.substack.com/p/getting-started-with-unit-testing</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/getting-started-with-unit-testing</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Sat, 18 Feb 2023 18:53:36 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!809-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1><strong>What it is?</strong></h1><p>The process of testing if the codes written are meeting expectations in one&#8217;s applications.</p><p>This is done to help test classes and functions faster with all possible scenarios.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Process is:</p><p>Provide some sample inputs to a function and their expected output.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!809-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!809-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 424w, https://substackcdn.com/image/fetch/$s_!809-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 848w, https://substackcdn.com/image/fetch/$s_!809-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!809-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!809-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg" width="422" height="142.30906593406593" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:491,&quot;width&quot;:1456,&quot;resizeWidth&quot;:422,&quot;bytes&quot;:224096,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!809-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 424w, https://substackcdn.com/image/fetch/$s_!809-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 848w, https://substackcdn.com/image/fetch/$s_!809-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!809-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd62ad1ae-0dd0-4730-af90-684a65deb5bc_2160x728.jpeg 1456w" sizes="100vw" loading="lazy" fetchpriority="high"></picture><div></div></div></a></figure></div><p>How to write test cases?</p><ul><li><p>Go to file &#8594; new &#8594; Target</p></li><li><p>Search test</p></li><li><p>Choose UI Testing Bundle</p></li></ul><pre><code>import XCTest
@testable&nbsp;import&nbsp;UnitTest

class&nbsp;UnitTestTests: XCTestCase {

   func&nbsp;testAdditions() {
&#9;
      let&nbsp;operations = MathOperations()
&#9;&#9;
      let&nbsp;result = operations.addNumbers(x: 1, y: 2)
&#9;&#9;
&#9;XCTAssertEqual(result, 3)
&#9;&#9;
      }// testAdditions

   func&nbsp;testMultiplications() {
&#9;&#9;
     let&nbsp;operations = MathOperations()
&#9;&#9;
     let&nbsp;result = operations.multiplyNumbers(x: 2, y: 2)
&#9;&#9;
     XCTAssertEqual(result, 4)
&#9;&#9;
   }// testMultiplications

   func&nbsp;testDivisions() {
&#9;&#9;
     let&nbsp;operations = MathOperations()
&#9;&#9;
     let&nbsp;result = operations.divideNumbers(x: 10, y: 2)
&#9;&#9;
     XCTAssertEqual(result, 5)
&#9;&#9;
   }// testMultiplications
&#9;&#9;
}</code></pre><p>The @testable line is basically importing our main folder where our app resides, so that we are able to test anything even those declared as private. This means, we can import any of our custom folders and files.</p><p>"XCTAssertEqual" makes sure the two arguments "result" and "3" are equal</p><p>The arguments passed are called <em>expressions</em>. So basically, we want the two expressions to be equal.</p><p>"XCTAssertEqual" can only be used when the class conform to the "XCTestCase" protocol imported from "XCTest"</p><p>Similarly we can test the following among others:</p><p>If an expression is true -&gt;&nbsp;&nbsp;XCTAssertTrue(expression: Bool)</p><p>If an expression is false -&gt; XCTAssertFalse(expression: Bool)</p><p>If an expression is nil -&gt; XCTAssertNil(expression: Any)</p><p>If the first expression is less than the second expression -&gt; XCTAssertLessThan(expression1: Comparable,expression2: Comparable)</p><h3>Testing in an app</h3><p>Consider the following partial code of a simple app</p><pre><code>
struct LoginView: View {
&#9;@State var email: String = ""
&#9;@State var password: String = ""
&#9;let isLoginSuccessful = FormValidation()

    var body: some View {
       VStack {
&#9;TextField("Email address: ", text: $email) &#9;&#9;&#9; 
            .keyboardType(.emailAddress)
&#9;SecureField("Password: ", text: $password)
&#9;Button("Login") {
&#9;   print(isLoginSuccessful.isLoginSuccessful(email: email, password: password))
&#9;}
      }//VStack
    }//body
}//struct

</code></pre><pre><code>
class FormValidation {
   func isEmailValid(email: String) -&gt; Bool {&#9;&#9;
&#9;let emailFormat = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
&#9;let emailPredicate = NSPredicate(format:"SELF MATCHES %@", emailFormat)
&#9;return emailPredicate.evaluate(with: email)
   }
&#9;
    func isFormValid(email: String, password: String) -&gt; Bool {
&#9;if !email.isEmpty &amp;&amp; !password.isEmpty {
&#9;&#9;return true
&#9;}
&#9;return false
    }
&#9;
&#9;
   func isLoginSuccessful(email: String, password: String) -&gt; String {&#9;&#9;
     if isEmailValid(email: email) &amp;&amp; isFormValid(email: email, password: password) {
&#9;return "Login Successful"
     }
&#9;&#9;
     return "Login unsuccessful"
   }
}</code></pre><p>Step 1: In the AppNameUnitTesting file</p><pre><code>import XCTest

class TestFormValidation: XCTestCase {

   let login = FormValidation()

&#9;// Successful test case
   func test_should_make_sure_email_is_valid() {
&#9;&#9;
&#9;let testEmail = "Jon@example.com"
&#9;&#9;
&#9;let actualResult = login.isEmailValid(email: testEmail)
&#9;&#9;
&#9;XCTAssertTrue(actualResult)
    }
&#9;
&#9;// A failed case since email is empty
   func test_should_make_sure_form_is_valid2() {
&#9;&#9;
&#9;let testEmail = ""
&#9;let testPassword = "23,nb%fd"
&#9;&#9;
&#9;let actualResult = login.isFormValid(email: testEmail, password: testPassword)
&#9;&#9;
&#9;XCTAssertTrue(actualResult)
   }
&#9;
&#9;// Successful case
   func test_should_make_sure_login_is_successful() {
&#9;&#9;
&#9;let testEmail = "jon@email.com"
&#9;let testPassword = "23,nb%fd"
&#9;&#9;
&#9;let actualResult = login.isLoginSuccessful(email: testEmail, password: testPassword)
&#9;&#9;
&#9;let expectedResult = "Login successful"
&#9;&#9;
&#9;XCTAssertEqual(actualResult, expectedResult)
    }
}
</code></pre><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[UI Testing in SwiftUI]]></title><description><![CDATA[How to access components and write test cases]]></description><link>https://ruwaydah.substack.com/p/ui-testing-in-swiftui</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/ui-testing-in-swiftui</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Sat, 18 Feb 2023 18:53:20 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Kl3X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Writing test is simply assessing in sequence, each component&#8217;s role and its expectations.</p><p>To understand the tests functions, consider the View below</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><pre><code><code>import SwiftUI

struct MealView: View {&#9;
&#9;@State var meals: [String] = []
&#9;@State var mealName: String = ""
&#9;@State var presentSheet: Bool = false
    var body: some View {
      NavigationView {
&#9;VStack {
&#9;  List(meals, id: \.self) { meal in
&#9;     Text(meal)
&#9;  }//List
&#9;   .accessibility(identifier: "mealList")
&#9;}//VStack
&#9; .sheet(isPresented: $presentSheet, onDismiss: {
&#9;     meals.append(mealName)
&#9;  }, content: {
      &#9;    AddMealScreen(mealTitle: $mealName)
&#9;  })
&#9;   .navigationTitle("Meal")
&#9;   .navigationBarItems(trailing: Button(action: {
&#9;&#9;presentSheet = true
&#9;     }, label: {
&#9;&#9;Image(systemName: "plus")
&#9;     })//Button
&#9;     .accessibility(identifier: "showAddMealButton")
&#9; )//navigationBarItems
     }//NavigationView
   }//body
}//MealView

struct AddMealScreen: View {
   @Binding var mealTitle: String
   @Environment(\.presentationMode) var presentationMode
   var body: some View {
&#9;   NavigationView {
&#9;     Form {
&#9;&#9;Section {
&#9;&#9;  TextField("Enter meal title", text: $mealTitle)&#9;&#9;&#9;&#9;   
                      .textFieldStyle(RoundedBorderTextFieldStyle())&#9;&#9;&#9; 
                      .accessibility(identifier: "addMealTextField")
&#9;&#9;}
&#9;&#9;Section {
&#9;          Button("Add") {
                         presentationMode.wrappedValue.dismiss()
&#9;&#9;  } //Button
&#9;&#9;&#9;.frame(maxWidth: .infinity)
&#9;&#9;&#9;.accessibility(identifier: "addMealButton")
&#9;        }
&#9;    }//Form
&#9;&#9;.navigationTitle("Add Meal")
&#9;}//NavigationView
  }//body
}</code></code></pre><p><strong>Note</strong>: accessibility(identifier: ) is used in unit testing to access any view.</p><p>Visual representation of the code above:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Kl3X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Kl3X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Kl3X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Kl3X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Kl3X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Kl3X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg" width="140" height="239.194847020934" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2122,&quot;width&quot;:1242,&quot;resizeWidth&quot;:140,&quot;bytes&quot;:88402,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Kl3X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Kl3X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Kl3X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Kl3X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dbfee7f-1ca5-49a3-83c4-ceaefb5443a7_1242x2122.jpeg 1456w" sizes="100vw" loading="lazy" fetchpriority="high"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FOXJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FOXJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 424w, https://substackcdn.com/image/fetch/$s_!FOXJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 848w, https://substackcdn.com/image/fetch/$s_!FOXJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!FOXJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FOXJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg" width="226" height="258.44193548387096" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1418,&quot;width&quot;:1240,&quot;resizeWidth&quot;:226,&quot;bytes&quot;:64246,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FOXJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 424w, https://substackcdn.com/image/fetch/$s_!FOXJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 848w, https://substackcdn.com/image/fetch/$s_!FOXJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!FOXJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11973e76-a2ed-4c7a-b8df-f4f2755250e6_1240x1418.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Q_D_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Q_D_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Q_D_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Q_D_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Q_D_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Q_D_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg" width="254" height="218.61996779388085" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1069,&quot;width&quot;:1242,&quot;resizeWidth&quot;:254,&quot;bytes&quot;:68230,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Q_D_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Q_D_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Q_D_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Q_D_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d27f108-6f87-4446-9f26-f9303ee800a1_1242x1069.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p>Now let&#8217;s begin with the test cases: </p><ul><li><p>Go to file &#8594; new &#8594; Target</p></li><li><p>Search test</p></li><li><p>Choose UI Testing Bundle</p></li></ul><p><strong>In the AppNameUITests file</strong></p><p><strong>Step 1</strong>: Import <em>XCTest</em></p><p>XCTest, in simple term, is a framework provided by Xcode to facilitate test writing and execution</p><p><strong>Step 2</strong>: Create a class that inherits from <em>XCTestCase.</em></p><p><strong>Step</strong> 3: Write the test functions</p><ol><li><p>We first need to launch the app</p><ol><li><p>To access the app we need to create an instance of the class XCUIApplication()</p></li></ol></li></ol><pre><code><code>&#9;let app = XCUIApplication()
&#9;app.launch()
</code></code></pre><p>      b. To add a new meal, we need to tap on the &#8220;+&#8221; button with identifier         &#8220;showAddMealButton&#8221;</p><pre><code><code>let addMealButton = app.buttons["showAddMealButton"]
&#9;&#9;addMealButton.tap()
</code></code></pre><p>c. To write tests, we need to evaluate each component&#8217;s expectation. Likewise, the addMealButton&#8217;s expectation is to show a modal.</p><p>To know if the modal screen is present, we added an identifier in our NavigationBarTitle in our ui. This way, if the title is present it means the modal screen is in view.</p><pre><code><code>let addMealNavBarTitle = app.staticTexts["Add Meal"]
</code></code></pre><p>d. The modal sliding up/down is an animation which may take some seconds. therefore we need to assess for this duration too else our test will timeout</p><p>So we await for the title&#8217;s existence for 1.0. Failing to exist will also result in failure of this test case.</p><pre><code>XCTAssert(addMealNavBarTitle.waitForExistence(timeout: 1.0))</code></pre><p>Full Code: </p><pre><code>import XCTest

class test_full_app_function: XCTestCase {
&#9;
&#9;func test_should_make_sure_meal_is_added_to_list() {
&#9;&#9;
&#9;  let app = XCUIApplication()
&#9;  app.launch()
&#9;&#9;
&#9;  let addNewMealButton = app.buttons["showAddMealButton"]
&#9;  addNewMealButton.tap()
&#9;&#9;
&#9;  let addMealNavBarTitle = app.staticTexts["Add Meal"]&#9;
&#9;  XCTAssert(addMealNavBarTitle.waitForExistence(timeout: 1.0))
&#9;&#9;
&#9;  let mealTextField = app.textFields["addMealTextField"]
&#9;  mealTextField.tap()
&#9;  mealTextField.typeText("Happy meal")
&#9;&#9;
&#9;  let addMealButton = app.buttons["addMealButton"]
&#9;  addMealButton.tap()
&#9;&#9;
&#9;  let mealList = app.tables["mealList"]
&#9;  let _ = mealList.waitForExistence(timeout: 1.0)
&#9;&#9;
&#9; let totalMealItems = mealList.descendants(matching:  
           .staticText).count
&#9;&#9;
&#9;XCTAssertEqual(1, totalMealItems)
     }
}</code></pre><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Unit testing v/s UI Testing]]></title><description><![CDATA[What is the difference between Unit Testing and UI Testing]]></description><link>https://ruwaydah.substack.com/p/unit-testing-vs-ui-testing</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/unit-testing-vs-ui-testing</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Sat, 18 Feb 2023 18:53:05 GMT</pubDate><content:encoded><![CDATA[<p>Unit testing seeks to give a rapid feedback to developers to assess the correctness of their code. </p><p>UI testing validates the application as a whole. It ensures that the final product performs as expected by users.</p><p>In Unit tests you need to have a test case class for each class in your app. Each test case should then focus on a single class and test it as thoroughly as possible. Therefore, Unit tests have access to the code (modules and classes) of the app.</p><p> UI tests do&nbsp;<em>not</em> &nbsp;have access to the code. However, it makes use of the accessibility features of Xcode to test for specific components.</p><h5><a href="https://ruwaydah.substack.com/publish/post/103345642">A peek into Unit Testing</a></h5><h5><a href="https://ruwaydah.substack.com/publish/post/103348667">A peek into UI Testing</a></h5><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Group v/s Section in SwiftUI]]></title><description><![CDATA[When and how to use Group and Section]]></description><link>https://ruwaydah.substack.com/p/group-vs-section-in-swiftui</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/group-vs-section-in-swiftui</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Mon, 13 Feb 2023 18:49:46 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!a2qi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>Group</h3><p>Group does nothing to our ui except that it group multiple views having the same properties, such as styling.</p><pre><code>HStack {
   Button("Delete") {
     print("Delete")
   }
    .buttonStyle(.bordered) 
    .tint(.red)
&#9;&#9;&#9;&#9;
   Group {
&#9;Button("Ok") {
          print("Ok")
        }
&#9;Button("Done") {
&#9;  print("Done")
&#9;}
  }//Group
   .buttonStyle(.borderedProminent)
   .tint(.green)
}
</code></pre><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a2qi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a2qi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 424w, https://substackcdn.com/image/fetch/$s_!a2qi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 848w, https://substackcdn.com/image/fetch/$s_!a2qi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!a2qi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a2qi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg" width="528" height="222.4655172413793" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:391,&quot;width&quot;:928,&quot;resizeWidth&quot;:528,&quot;bytes&quot;:49785,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!a2qi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 424w, https://substackcdn.com/image/fetch/$s_!a2qi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 848w, https://substackcdn.com/image/fetch/$s_!a2qi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!a2qi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5657c301-af47-4870-bd96-bd94b411b44a_928x391.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p><strong>Note:</strong> Each <em>Group</em> can have up to 10 view components only, be it Text, buttons, etc. To display more views, another group is to be created. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><pre><code>Form {
   Group {
     Text("1")
     Text("2")
     Text("3")
     Text("4")
     Text("5")
     Text("6")
     Text("7")
     Text("8")
     Text("9")
     Text("10")
  }
  Group {
    Text("11")
  }
}</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fYFV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fYFV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 424w, https://substackcdn.com/image/fetch/$s_!fYFV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 848w, https://substackcdn.com/image/fetch/$s_!fYFV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 1272w, https://substackcdn.com/image/fetch/$s_!fYFV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fYFV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png" width="215" height="316.61383285302594" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:511,&quot;width&quot;:347,&quot;resizeWidth&quot;:215,&quot;bytes&quot;:17662,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fYFV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 424w, https://substackcdn.com/image/fetch/$s_!fYFV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 848w, https://substackcdn.com/image/fetch/$s_!fYFV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 1272w, https://substackcdn.com/image/fetch/$s_!fYFV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ccbc293-3545-4e48-b4f4-f06eb7306fce_347x511.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Section</h3><p><em>Section</em> actually creates sections in our data modifying our ui.</p><pre><code><code>Form {
   Section {
&#9;Text("1")
&#9;Text("2")
&#9;Text("3")
&#9;Text("4")
&#9;Text("5")
&#9;Text("6")
&#9;Text("7")
&#9;Text("8")
&#9;Text("9")
&#9;Text("10")
   }
   Section {
&#9;Text("11")
   }
}</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fsX2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fsX2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 424w, https://substackcdn.com/image/fetch/$s_!fsX2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 848w, https://substackcdn.com/image/fetch/$s_!fsX2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 1272w, https://substackcdn.com/image/fetch/$s_!fsX2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fsX2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png" width="218" height="324.5777777777778" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:536,&quot;width&quot;:360,&quot;resizeWidth&quot;:218,&quot;bytes&quot;:19372,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fsX2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 424w, https://substackcdn.com/image/fetch/$s_!fsX2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 848w, https://substackcdn.com/image/fetch/$s_!fsX2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 1272w, https://substackcdn.com/image/fetch/$s_!fsX2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab47100-a5dd-4c1c-889a-2ad7dc560704_360x536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h4>Section with a header</h4><pre><code>Section {
&#9;Text("Section 1")
&#9;Image(systemName: "sparkles")
&#9;&#9;.resizable()
&#9;&#9;.frame(width: 50, height: 50, alignment: .center)
} header: {&#9;&#9;&#9;&#9;&#9;
&#9;Text("Section header")
} //header
</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!n2NP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n2NP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 424w, https://substackcdn.com/image/fetch/$s_!n2NP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 848w, https://substackcdn.com/image/fetch/$s_!n2NP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!n2NP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!n2NP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg" width="530" height="268.41384863123994" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:629,&quot;width&quot;:1242,&quot;resizeWidth&quot;:530,&quot;bytes&quot;:64484,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!n2NP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 424w, https://substackcdn.com/image/fetch/$s_!n2NP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 848w, https://substackcdn.com/image/fetch/$s_!n2NP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!n2NP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6611cbe-4537-4c29-8894-cdc710fa5067_1242x629.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h4>Section with a footer</h4><pre><code>Section {
&#9;Text("Section 1")
&#9;Image(systemName: "sparkles")
&#9;&#9;.resizable()
&#9;&#9;.frame(width: 50, height: 50, alignment: .center)
} header: {&#9;&#9;&#9;&#9;&#9;
&#9;Text("Section header")
} footer: {
&#9;Text("Section footer")
}</code></pre><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Px39!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Px39!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Px39!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Px39!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Px39!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Px39!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg" width="558" height="239.0144927536232" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:532,&quot;width&quot;:1242,&quot;resizeWidth&quot;:558,&quot;bytes&quot;:64390,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Px39!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Px39!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Px39!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Px39!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9713123e-2071-4c00-8616-f31d1816dc2b_1242x532.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4>Center a button in a section</h4><pre><code>Section {
   Button(action: {
     print("Button tapped")
   }, label: {
     Text("Tap")
&#9;.frame(width: 100)
  })
   .tint(.yellow)
   .buttonStyle(.borderedProminent)
   .padding()
   .frame(maxWidth: .infinity)
  } header: {
&#9;Text("Section Two")
  } footer: {
&#9;Text("Button")
  }
}</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HINu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HINu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 424w, https://substackcdn.com/image/fetch/$s_!HINu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 848w, https://substackcdn.com/image/fetch/$s_!HINu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!HINu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HINu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg" width="366" height="309.7149758454106" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1051,&quot;width&quot;:1242,&quot;resizeWidth&quot;:366,&quot;bytes&quot;:110041,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HINu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 424w, https://substackcdn.com/image/fetch/$s_!HINu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 848w, https://substackcdn.com/image/fetch/$s_!HINu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!HINu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F804159a3-fbf5-434f-b04a-318c7e2a9f5f_1242x1051.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h4>Remove background from section</h4><pre><code>Section {
    Button(action: {
&#9;print("Button tapped")
    }, label: {
      Text("Tap")
        .frame(width: 100)
    })&#9;
     .listRowBackground(Color.clear)
     .tint(.yellow)
     .buttonStyle(.borderedProminent)
     .padding()
     .frame(maxWidth: .infinity)
   } header: {
&#9;Text("Section Two")
   }
}</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vm38!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vm38!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 424w, https://substackcdn.com/image/fetch/$s_!vm38!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 848w, https://substackcdn.com/image/fetch/$s_!vm38!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!vm38!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vm38!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg" width="396" height="298.7536231884058" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:937,&quot;width&quot;:1242,&quot;resizeWidth&quot;:396,&quot;bytes&quot;:95536,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vm38!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 424w, https://substackcdn.com/image/fetch/$s_!vm38!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 848w, https://substackcdn.com/image/fetch/$s_!vm38!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!vm38!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f94dcd2-256e-4f74-83db-5788ec4c8951_1242x937.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Note: </strong>Very often <em>Section </em>and <em>G</em>roup are used within the Form component to allow a scrollable view. </p><p>Form in itself is a container used to wrap lists of views. </p><pre><code>NavigationView {
  VStack {&#9;&#9;&#9;&#9;
      Form {
&#9;Section {
&#9;    Group {&#9;&#9;&#9;&#9;&#9;&#9;&#9;    
                TextField("Name", text: $name)&#9;&#9;&#9;&#9;&#9; 
                TextField("Email", text: $email)&#9;&#9;&#9;&#9;   
            }//group&#9;&#9;&#9;&#9; 
              .textFieldStyle(RoundedBorderTextFieldStyle())
&#9;&#9;&#9;&#9;&#9;
&#9;} header: {
&#9;   Text("Welcome Subscribers")
&#9;}//section
&#9;
        Button("Save") {
&#9;   print("\(name) saved!")
&#9;}
&#9;.tint(.green)
&#9;.buttonStyle(.borderless)
&#9;.frame(maxWidth: .infinity)
&#9;&#9;&#9;&#9;&#9;&#9;
    }// form
  }
   .navigationBarTitle("Forms")
}</code></pre><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Smsh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Smsh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Smsh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Smsh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Smsh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Smsh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg" width="446" height="361.61191626409015" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1007,&quot;width&quot;:1242,&quot;resizeWidth&quot;:446,&quot;bytes&quot;:109335,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Smsh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Smsh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Smsh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Smsh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6abff673-767b-4ff5-a99a-c168dfebfd16_1242x1007.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Toolbar in SwiftUI]]></title><description><![CDATA[When and how to use a toolbar.]]></description><link>https://ruwaydah.substack.com/p/toolbar-in-swiftui</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/toolbar-in-swiftui</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Fri, 03 Feb 2023 17:33:48 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!TUxV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A toolbar is a means to have immediate access to commands.</p><h2>Using a toolbar</h2><p>A toolbar can be attached to any kind of view builder in swift, e.g to a list</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p><em>.toolbar</em> has as content <em>ToolbarItem, ToolbarItemGroup</em></p><p>Both <em>ToolbarItem</em> and <em>ToolbarItemGroup</em> takes two parameters: <em>placement</em> and <em>content</em></p><p>a. placement &#8594; where to place the items: either in toolbar or navigation bar</p><ol><li><p>.navigationBarTrailing</p></li><li><p>.navigationBarLeading</p></li><li><p>.bottomBar</p></li><li><p>.tabBar</p></li><li><p>.automatic</p></li><li><p>.windowToolbar</p></li></ol><p>b. content &#8594; the items of the toolbar</p><ol><li><p>For one item &#8594; ToolbarItem</p><pre><code><code>.toolbar {&#9;&#9;&#9;
    ToolbarItem(placement: .navigationBarTrailing) {
&#9;Button {
&#9;  print("New button pressed")
&#9;} label: {
&#9;  Image(systemName: "plus")
&#9;}
    } // ToolbarItem
}//toolbar</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TUxV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TUxV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 424w, https://substackcdn.com/image/fetch/$s_!TUxV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 848w, https://substackcdn.com/image/fetch/$s_!TUxV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!TUxV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TUxV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg" width="226" height="390.85990338164254" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2148,&quot;width&quot;:1242,&quot;resizeWidth&quot;:226,&quot;bytes&quot;:250352,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TUxV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 424w, https://substackcdn.com/image/fetch/$s_!TUxV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 848w, https://substackcdn.com/image/fetch/$s_!TUxV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!TUxV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa5115b-5855-4783-a4a8-ac7647d88caf_1242x2148.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">One item toolbar</figcaption></figure></div></li><li><p>For more than one item &#8594; ToolbarItemGroup</p><pre><code><code>.toolbar {
&#9;ToolbarItemGroup(placement: .bottomBar) {
&#9;      // Button one
&#9;   Button {&#9;&#9;&#9;&#9;
              print("Home button pressed")
&#9;   } label: {
&#9;      Image(systemName: "house")
&#9;   }
&#9;&#9;&#9;&#9;
&#9;   Spacer()
&#9;&#9;&#9;&#9;
&#9;     // Button two
&#9;    Button {
&#9;&#9;print("Camera button pressed")
&#9;&#9;} label: {
&#9;&#9;  Image(systemName: "camera")
&#9;&#9;}
&#9;&#9;&#9;&#9;
&#9;&#9;Spacer()
&#9;&#9;&#9;&#9;
&#9;&#9;// Button three
&#9;     Button {
&#9;&#9;print("Settings button pressed")
&#9;     } label: {
&#9;&#9;Image(systemName: "gear")
&#9;     }
} // ToolbarItemGroup</code></code></pre></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WLMd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WLMd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 424w, https://substackcdn.com/image/fetch/$s_!WLMd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 848w, https://substackcdn.com/image/fetch/$s_!WLMd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!WLMd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WLMd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg" width="232" height="397.31400966183577" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2127,&quot;width&quot;:1242,&quot;resizeWidth&quot;:232,&quot;bytes&quot;:342750,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WLMd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 424w, https://substackcdn.com/image/fetch/$s_!WLMd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 848w, https://substackcdn.com/image/fetch/$s_!WLMd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!WLMd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb916f2-488e-4172-9e8e-a4c74f4aa84f_1242x2127.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">More than one item toolbar</figcaption></figure></div><h3>Changing colors of the toolbar item</h3><ol><li><p>Using <em>.accentColor</em> [<em>will be deprecated in future version of iOS, Use the asset catalog&#8217;s accent Color or ViewTint(_:) instead</em>]</p></li></ol><pre><code><code>.toolbar {
   ToolbarItem(placement: .navigationBarTrailing) {   &#9;&#9;&#9;&#9;   
     Button {
&#9;print("New button pressed")
     } label: {
&#9;Image(systemName: "plus")
     }//label
   } // ToolbarItem
&#9;&#9;&#9;
   ToolbarItemGroup(placement: .bottomBar) {
&#9;// Button one
     Button {
&#9;print("Home button pressed")
     } label: {
&#9;Image(systemName: "house")
     }&#9;&#9;&#9;
     Spacer() 
&#9;&#9;&#9;&#9;
&#9;// Button two
     Button {
&#9;print("Camera button pressed")
     } label: {
&#9;Image(systemName: "camera")
     }
     Spacer()
&#9;&#9;&#9;&#9;
&#9;// Button three
      Button {
&#9;print("Settings button pressed")
      } label: {
&#9;Image(systemName: "gear")
&#9;&#9;&#9;&#9;}
      } // ToolbarItemGroup
}//toolbar
  .accentColor(.red
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cEX7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cEX7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 424w, https://substackcdn.com/image/fetch/$s_!cEX7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 848w, https://substackcdn.com/image/fetch/$s_!cEX7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!cEX7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cEX7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg" width="278" height="475.42028985507244" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2124,&quot;width&quot;:1242,&quot;resizeWidth&quot;:278,&quot;bytes&quot;:294902,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!cEX7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 424w, https://substackcdn.com/image/fetch/$s_!cEX7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 848w, https://substackcdn.com/image/fetch/$s_!cEX7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!cEX7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23afb7c9-6b4c-4921-ba91-61b9ca1850f8_1242x2124.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Colored items toolbar</figcaption></figure></div><p></p><h3>Visibility of toolbar </h3><p>[iOS 16]</p><pre><code>Button {
   showToolbar.toggle()
} label: {
   Image(systemName: "pencil.tip.crop.circle")
}
 .toolbar(showToolbar ? .visible : .hidden, for: .bottomBar)</code></pre><h3>When to use a toolbar?</h3><h4>Toolbar v/s tab view</h4><p>Both a toolbar(placement: .bottomBar) and a tab bar are placed at the bottom of the app screen. Each containing buttons for performing specific actions and are visually similar.</p><p><strong>So when to use either?</strong></p><p>A toolbar contains buttons for performing actions relevant to the current view or current content within that page.</p><p>A tab bar provides the ability to navigate between different sections/pages of an app.</p><p>toolbar &#8594; perform action</p><p>tab bar &#8594; navigation</p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Firestore in SwiftUI]]></title><description><![CDATA[Performing CRUD operations in SwiftUI]]></description><link>https://ruwaydah.substack.com/p/firestore-in-swiftui</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/firestore-in-swiftui</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Mon, 30 Jan 2023 10:15:14 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Jzdf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Firestore makes use of collections as storage structure. Each collection has one or more documents which are made up of attributes that contain the actual data.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jzdf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jzdf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 424w, https://substackcdn.com/image/fetch/$s_!Jzdf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 848w, https://substackcdn.com/image/fetch/$s_!Jzdf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 1272w, https://substackcdn.com/image/fetch/$s_!Jzdf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jzdf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png" width="450" height="242.30769230769232" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:420,&quot;width&quot;:780,&quot;resizeWidth&quot;:450,&quot;bytes&quot;:11443,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jzdf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 424w, https://substackcdn.com/image/fetch/$s_!Jzdf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 848w, https://substackcdn.com/image/fetch/$s_!Jzdf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 1272w, https://substackcdn.com/image/fetch/$s_!Jzdf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ace75ac-f271-45e4-a977-573e1740abfb_780x420.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Structure of firestore storage</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!e_xM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!e_xM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 424w, https://substackcdn.com/image/fetch/$s_!e_xM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 848w, https://substackcdn.com/image/fetch/$s_!e_xM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 1272w, https://substackcdn.com/image/fetch/$s_!e_xM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!e_xM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png" width="430" height="220.2439024390244" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:420,&quot;width&quot;:820,&quot;resizeWidth&quot;:430,&quot;bytes&quot;:10107,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!e_xM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 424w, https://substackcdn.com/image/fetch/$s_!e_xM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 848w, https://substackcdn.com/image/fetch/$s_!e_xM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 1272w, https://substackcdn.com/image/fetch/$s_!e_xM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F519ad2fd-907f-421c-82d6-0f64d3dc02fb_820x420.png 1456w" sizes="100vw"></picture><div></div></div></a><figcaption class="image-caption">Structure with examples</figcaption></figure></div><p>Similarly, firestore can store many collections.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>References</h2><p>A reference can be created for collection as well as document. Creating a reference does not perform any network operation, it only point to a location in the database.</p><p>For e.g reference to a collection</p><pre><code>let mealCollectionRef = db.collection("Meal")</code></pre><p>For e.g reference to a document</p><pre><code>let mealOneDocumentRef = db.collection("Meal").document("Meal 1")</code></pre><p><strong>Note</strong>: A document can have a collection too. For instance, a review needs data from the reviewer and the review itself.</p><ul><li><p>Meals</p><ul><li><p>Meal one</p><ul><li><p><code>title : "Burgers"</code></p></li><li><p>reviews</p><ul><li><p>review one</p></li></ul><p><code>from : "alex"</code></p><p><code>review : "Good"</code></p><ul><li><p>review two</p></li></ul><p><code>from : "tom"</code></p><p><code>review : "bad"</code></p></li></ul></li><li><p>Meal Two</p></li></ul></li></ul><p>In the above, we have reviews as a sub-collection of document &#8220;Meal one&#8221; since reviews contain large number of data.</p><h3>Referencing a sub-collection</h3><pre><code>let reviewRef = db.collection("Meals").document("Meal one").collection("reviews").document("review one")</code></pre><p><strong>Note</strong>: sub-collections need to be deleted manually, even if the parent document and collection are deleted</p><h3>Create references</h3><p>Document reference with generated id</p><pre><code><code>var docRef: DocumentReference? = nil
</code></code></pre><p>Collection Reference with generated id</p><pre><code><code>var colRef: CollectionReference? = nil
</code></code></pre><h2>Read Documents</h2><h4>Multiple documents</h4><p>To fetch multiple documents in a collection, we use getDocuments().</p><p>getDocuments() returns documents in querySnapshot as a list.</p><p>querySnapshots contain several documents, from which we can extract several or one document.</p><pre><code><code>db.collection("meals").getDocuments() { (querySnapshot, error)  in
&#9;if let error = error {
&#9;&#9;print("Error getting documents: \\(error)")
&#9;} else {
&#9;&#9;let documents = querySnapshot!.documents
&#9;&#9;print("\\(documents)")
&#9;}
}

// OUTPUT
//[&lt;FIRQueryDocumentSnapshot: 0x2822e8140&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e81e0&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e8280&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e8320&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e83c0&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e8460&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e8500&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e85a0&gt;, 
// &lt;FIRQueryDocumentSnapshot: 0x2822e8640&gt;, 
//&lt;FIRQueryDocumentSnapshot: 0x2822e86e0&gt;]
</code></code></pre><h4>Single document</h4><p>To fetch a single document, we loop through the documents obtained from querySnapshots .documents.</p><pre><code><code>db.collection("meals").getDocuments() { (querySnapshot, error) in
&#9;if let error = error { 
&#9;&#9;print(" Cannot fetch documents")
&#9;} else {
&#9;&#9;for document in querySnapshots!.documents {
&#9;&#9;   print("\\(document.data())")
&#9;        }//for
&#9;}//else
}//getDocument
</code></code></pre><h2>Get data</h2><p>Fetching data from a single document using .data from document</p><pre><code><code>db.collection("meals").getDocuments() { (querySnapshot, error)  in
   if let error = error {
      print("Error getting documents: \\(error)")
   } else {
        let documents = querySnapshot!.documents
&#9;print("Documents list: \\(documents)")
&#9;for document in documents {
&#9;    print("Data from document: \\(document.data())")
&#9;}
&#9;    print("\\(documents)")
    }//else
}//getDocuments()

&#9;// OUTPUT
//Data from document: ["title": Mac and cheese, "price": 125, "quantity": 4]
//Data from document: ["title": burger, "price": 125.5, "quantity": 2]
//Data from document: ["title": Mac and cheese, "price": 125, "quantity": 4]
//Data from document: ["title": Mac and cheese, "price": 125, "quantity": 4]
//Data from document: ["title": Pasta, "price": 467, "quantity": 6]
//Data from document: ["title": Mac and cheese, "price": 125, "quantity": 4]
//Data from document: ["title": Mac and cheese, "price": 125, "quantity": 4]
//Data from document: ["title": Pizza, "price": 400, "quantity": 2]
//Data from document: ["title": Mac and cheese, "price": 125, "quantity": 4]
//Data from document: ["title": Mac and cheese, "price": 125, "quantity": 4]
</code></code></pre><h4>Extracting single attributes</h4><pre><code><code>db.collection("meals").getDocuments() { (querySnapshot, error)  in
&#9;if let error = error {
&#9;   print("Error getting documents: \\(error)")
&#9;} else {
&#9;  let documents = querySnapshot!.documents
&#9;   //print("Documents list: \\(documents)")
&#9;  for document in documents {
&#9;   //print("Data from document: \\(document.data())")
&#9;&#9;let data = document.data()
&#9;&#9;let title = data["title"]
&#9;&#9;let price = data["price"]
&#9;&#9;let quantity = data["quantity"]
&#9;&#9;print("title: \\(title ?? "No title")")
&#9;&#9;print("price: \\(price ?? "No price")")
&#9;        print("quantity: \\(quantity ?? "No quantity")")&#9;
           }//for&#9;&#9;&#9;
&#9; }//else
}//getDocuments

   // OUTPUT
//title: Mac and cheese
//price: 125
//quantity: 4
//title: burger
//price: 125.5
//quantity: 2
//title: Pizza
//price: 400
//quantity: 2
</code></code></pre><h2>Add data</h2><h3>Adding data with specific document id</h3><pre><code><code>let data: [String: Any] = [
&#9;&#9;"title": "Grilled lobster",
&#9;&#9;"price": 30,
&#9;&#9;"quantity": 2,
&#9;&#9;"type": "Dinner"
]

func pushData() {
&#9;db.collection("meals").document("five").setData(data) { err in
&#9;&#9;if let err = err {
&#9;&#9;&#9;print("Error writing to document: \\(err)")
&#9;&#9;} else {
&#9;&#9;&#9;print("Data successfully written to doc")
&#9;&#9;}//else&#9;
&#9;}//setData
}//Push data
</code></code></pre><h3>Adding data with auto-generated document id</h3><pre><code><code>docRef = db.collection("meals").addDocument(data: data) { err in
&#9;if let err = err {
&#9;&#9;print("Error adding document: \\(err)")
&#9;} else {
        &#9;print("Document \\(self.docRef!.documentID) added"). &#9;&#9;      
        }&#9;
}
</code></code></pre><h3>Adding data from classes/struct</h3><pre><code><code>public struct Place: Codable {
&#9;let name: String
&#9;let isCapital: Bool?
&#9;let population: Int?
&#9;
&#9;enum CodingKeys: String, CodingKey {
&#9;&#9;case name
&#9;&#9;case isCapital = "capital"
&#9;&#9;case population
&#9;}//enum
}//struct
</code></code></pre><pre><code><code>// In ObservableObject class
let places = Place(name: "China", isCapital: false, population: 1449323776)
do {
   try db.collection("Places").document("Asia").setData(from: places)&#9;&#9;} catch let error {
   print("Error writing ro firestore \\(error)")
}
</code></code></pre><p><strong>Note:</strong> You may get an error &#8220;Extraneous argument label 'from:' in call&#8221;. This is because firestore makes use of an extension (FirebaseFirestoreSwift) to be able to save custom objects such as struct.</p><p><strong>Fix</strong>: import FirebaseFirestoreSwift.</p><p>In case this is missing from your imports, just go to Targets &#8594; Frameworks, Libraries, and Embedded Content. Click on +, search for the dependency: &#8220;FirestoreFirebaseSwift&#8221; and click on add</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TBvc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TBvc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 424w, https://substackcdn.com/image/fetch/$s_!TBvc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 848w, https://substackcdn.com/image/fetch/$s_!TBvc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 1272w, https://substackcdn.com/image/fetch/$s_!TBvc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TBvc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png" width="778" height="166" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:166,&quot;width&quot;:778,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:18110,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TBvc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 424w, https://substackcdn.com/image/fetch/$s_!TBvc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 848w, https://substackcdn.com/image/fetch/$s_!TBvc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 1272w, https://substackcdn.com/image/fetch/$s_!TBvc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9ca3001-0cb2-436e-a049-813618ad5d8e_778x166.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Adding dependency in targets</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IgsU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IgsU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 424w, https://substackcdn.com/image/fetch/$s_!IgsU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 848w, https://substackcdn.com/image/fetch/$s_!IgsU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 1272w, https://substackcdn.com/image/fetch/$s_!IgsU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IgsU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png" width="316" height="361.92118226600985" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:465,&quot;width&quot;:406,&quot;resizeWidth&quot;:316,&quot;bytes&quot;:64587,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IgsU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 424w, https://substackcdn.com/image/fetch/$s_!IgsU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 848w, https://substackcdn.com/image/fetch/$s_!IgsU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 1272w, https://substackcdn.com/image/fetch/$s_!IgsU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35235e7a-a114-48ee-ab53-8492cc8867b7_406x465.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">FirebaseFirestoreSwift dependency</figcaption></figure></div><p>If using pods:</p><pre><code><code>pod 'FirebaseFirestoreSwift'
</code></code></pre><h2>Updating data</h2><pre><code><code>db.collection("Places").document("Asia").updateData(["name": "Australia", "capital":false]) { error in
&#9;if let error = error {
&#9;   print("Error updating document: \\(error)")
&#9;} else {
&#9;   print("Document successfully updated")
&#9;}
}
</code></code></pre><h3>Update data using a timeStamp</h3><pre><code><code>db.collection("Places").document("Asia").updateData(["lastUpdated":FieldValue.serverTimestamp()]) { error in
&#9;if let error = error {
&#9;&#9;print("Error updating document: \\(error)")
&#9;} else {
&#9;&#9;print("Document successfully updated")
&#9;}
}
</code></code></pre><h3>Update element in an array</h3><pre><code><code>db.collection("Places").document("Asia").updateData(["Ocean": FieldValue.arrayUnion(["Pacific"]) { error in
&#9;if let error = error {
&#9;&#9;print("Error updating document: \\(error)")
&#9;} else {
&#9;&#9;print("Document successfully updated")
&#9;}
}
</code></code></pre><h3>Incrementing number value</h3><p>Passing no argument will increase the value by 1</p><pre><code><code>db.collection("Places").document("Asia").updateData(["population": FieldValue.increment(Int64(10))]) { error in
&#9;if let error = error {
&#9;   print("Error updating document: \\(error)")
&#9;} else {
&#9;   print("Document successfully updated")
&#9;}
}
</code></code></pre><p><strong>Note</strong>: FieldValue.increment works only on Int64 or Double</p><h3>Deleting a field</h3><p>To mark a field for deletion we use updateData</p><pre><code><code>db.collection("Places").document("Asia").updateData(["population": FieldValue.delete()]) { error in
&#9;&#9;&#9;if let error = error {
&#9;&#9;&#9;&#9;print("Error updating document: \\(error)")
&#9;&#9;&#9;} else {
&#9;&#9;&#9;&#9;print("Document successfully updated")
&#9;&#9;&#9;}
&#9;&#9;}
</code></code></pre><h2>Delete a document</h2><pre><code><code>db.collection("Places").document("Asia").delete() { err in
    if let err = err {
        print("Error removing document: \\(err)")
    } else {
        print("Document successfully removed!")
    }
}
</code></code></pre><h1>Example</h1><h3>Step 1: Initialize firestore</h3><pre><code><code>import FirebaseCore
import FirebaseFirestore

FirebaseApp.configure()

let db = Firestore.firestore()
</code></code></pre><h3>Step 2: Create a model</h3><pre><code><code>import Foundation

struct Meal: Identifiable {
&#9;var id = UUID()
&#9;var title: String
&#9;var price: Double
&#9;var quantity: Int
&#9;
}
</code></code></pre><h3>Step 3: Create a view</h3><pre><code><code>struct MealView: View {
    @StateObject var viewModel = MealsViewModel()
    var body: some View {
&#9;List(viewModel.meals) { meal in
&#9;   VStack(alignment: .leading) {&#9;&#9;&#9;     
               Text(meal.title)
&#9;&#9;  .font(.headline)
&#9;&#9;Text("\\(meal.price)")
&#9;&#9;  .font(.subheadline)
&#9;&#9;Text("\\(meal.quantity)")
&#9;&#9;   .font(.footnote)
&#9;    }//VStack
&#9; }//List
&#9;.navigationTitle("Meals")
&#9;.onAppear() {
&#9;   self.viewModel.fetchData()
&#9;}
    }//body
}//MealView
</code></code></pre><h3>Step 4: Create a viewModel</h3><pre><code><code>import Foundation
import FirebaseFirestore

class MealsViewModel: ObservableObject {&#9;
  @Published var meals = [Meal]()
  private var db = FirebaseManager.shared.firestore
  private var docRef : DocumentReference? = nil&#9;
&#9;
   func fetchData() {
    db.collection("meals").addSnapshotListener { (querySnapshot, error) in
        guard let documents = querySnapshot?.documents else {
&#9;    print("No documents")
&#9;    return
&#9;}
&#9;self.meals = documents.map {
&#9;   queryDocumentSnapshot -&gt; Meal in
&#9;   let data = queryDocumentSnapshot.data()
&#9;   let title = data["title"] as? String ?? ""
&#9;   let price = data["price"] as? Double ?? 0.0
&#9;   let quantity = data["quantity"] as? Int ?? 0
&#9;&#9;&#9;&#9;
&#9;return Meal(id: .init(), title: title, price: price, quantity: quantity)
&#9;}&#9;&#9;
     }
   }// Fetch data
&#9;
   func pushData() {
&#9;docRef = db.collection("meals").addDocument(data: ["title": "Mac and cheese", "price": 125, "quantity": 4]) { err in
&#9;if let err = err {
&#9;   print("Error adding document: \\(err)")
&#9;} else {
&#9;    print("Document \\(self.docRef!.documentID) added")
&#9;}&#9;
     }
   }//Push data
}
</code></code></pre><p>The <em>meals</em> variable is wrapped with the <em>@Published</em> property. We use <em>@Published</em> property wrapper for all variable we want our view(UI) to listen to.</p><p>To be able to use the @Published property wrapper, the class must conform to the <em>ObservableObject</em> protocol.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Core Data in SwiftUI]]></title><description><![CDATA[Basics of using Core Data in SwiftUI]]></description><link>https://ruwaydah.substack.com/p/ada</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/ada</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Thu, 19 Jan 2023 14:31:00 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!S5bS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Core data uses persistent data storage to save an application&#8217;s information onto the device itself, that is, the data is available offline.</p><h2>Step 1: Create data model</h2><ol><li><p>Create a data model file that will store our entities and attributes</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!V0zH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!V0zH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 424w, https://substackcdn.com/image/fetch/$s_!V0zH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 848w, https://substackcdn.com/image/fetch/$s_!V0zH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 1272w, https://substackcdn.com/image/fetch/$s_!V0zH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!V0zH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png" width="347" height="198" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:198,&quot;width&quot;:347,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:21168,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!V0zH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 424w, https://substackcdn.com/image/fetch/$s_!V0zH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 848w, https://substackcdn.com/image/fetch/$s_!V0zH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 1272w, https://substackcdn.com/image/fetch/$s_!V0zH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3a3899b-0d3c-48d8-b52f-bf8332e6635c_347x198.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><ol start="2"><li><p>Add entities and attributes. Given e.g below is a boolean value which is not optional and has &#8220;No&#8221; as the default value.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sllr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sllr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 424w, https://substackcdn.com/image/fetch/$s_!sllr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 848w, https://substackcdn.com/image/fetch/$s_!sllr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 1272w, https://substackcdn.com/image/fetch/$s_!sllr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sllr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png" width="1128" height="137" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:137,&quot;width&quot;:1128,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:43466,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sllr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 424w, https://substackcdn.com/image/fetch/$s_!sllr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 848w, https://substackcdn.com/image/fetch/$s_!sllr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 1272w, https://substackcdn.com/image/fetch/$s_!sllr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ff5de-5d90-4e9c-be3e-6c74451548a8_1128x137.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><h2>Step 2: Load model and actual data</h2><ol><li><p>Create a data controller file of type swift file.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SIiV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SIiV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 424w, https://substackcdn.com/image/fetch/$s_!SIiV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 848w, https://substackcdn.com/image/fetch/$s_!SIiV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 1272w, https://substackcdn.com/image/fetch/$s_!SIiV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SIiV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png" width="261" height="235" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f5c67087-7019-487a-8618-93a496e1230d_261x235.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:235,&quot;width&quot;:261,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:38317,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SIiV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 424w, https://substackcdn.com/image/fetch/$s_!SIiV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 848w, https://substackcdn.com/image/fetch/$s_!SIiV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 1272w, https://substackcdn.com/image/fetch/$s_!SIiV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c67087-7019-487a-8618-93a496e1230d_261x235.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>Create a class DataController of type ObservableObject</p></li><li><p>Initialise a container variable to NSPersistentContainer</p></li></ol><p>NSPersistentContainer is responsible for loading a data model and give us access to entities and attributes.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>The NSPersistentContainer take as parameter the data model file created in step 1 rather than the entity file.</p><pre><code>import CoreData
import Foundation

class DataController: ObservableObject {
&#9;let container = NSPersistentContainer(name: "MealModel")
}</code></pre><ol start="4"><li><p>Load the actual data</p></li></ol><p>To have access to the actual data store in the user&#8217;s device, we call loadPersistentStore on our container</p><p>The loadPersistentStore takes as handler: description and error. This is used to display any kind of error encountered when loading the data.</p><pre><code>init() {
  container.loadPersistentStores { description, error in
     if let error = error {
&#9;print("Failed to load data: \(error.localizedDescription)")
     }&#9;&#9;&#9;&#9;&#9;&#9;&#9;   
}</code></pre><h2>Step 3: Preparation to use in SwiftUI</h2><p>Apps work with only one core data store at a time. Rather than each view creating their own store, our app creates it once when the app starts, stores it in swiftUI environment and make it accessible everywhere in our app.</p><p>We first create an instance of DataController and introduce it into our SwiftUI environment.</p><p>In the main file</p><pre><code>struct MealCoreData: App  {
// Creating instance
&#9;@StateObject private var dataController = DataController()
    var body: some Scene {
        WindowGroup {
&#9;&#9;// Introduction in environment
            ContentView().environment(\.managedObjectContext, dataController.container.viewContext)
&#9;&#9;&#9;&#9;
        }
    }
}</code></pre><p><strong>Tip</strong>: if using previews, managed object context should be injected into the preview struct for that particular view.</p><p><strong>Special Note:</strong> <em><strong>Managed Object Context</strong></em> deals with live data. I.e it only exist in Ram as long as the app is running, once the app closes it loses its data. Therefore to store it permanently, it needs to be saved into the persistent store.</p><p><strong>Advantage</strong>: Using live data is less time consuming and save resources as it foregoes the need of reading from and writing to disk constantly. Instead, it only does it once the data is actually saved.</p><h2>Step 4: CRUD</h2><p>Reading from and writing to core data is done through <em><strong>FetchRequest</strong></em>.</p><p><em>FetchRequest</em> takes at least one parameter that describe how we want the data to be sorted.</p><pre><code>@FetchRequest(sortDescriptors: []) var meals: FetchedResults&lt;Meal&gt;</code></pre><p>That creates a fetch request with no sorting, and places it into a property called&nbsp;meals that has the type&nbsp;<code>FetchedResults&lt;Meal&gt;.</code></p><p>Now meals can be manipulated as a simple swift array.</p><p>Let&#8217;s create a simple UI for meal, so we can perform CRUD.</p><pre><code>struct ContentView: View {
    let title = ["Burger", "Spicy Burger", "Pizza", "Spaghetti", "Chicken BBQ", "Lamb chop", "Chop suey", "Soya beans", "Baked beans", "Plain rice"]

   @FetchRequest(sortDescriptors: []) var meals: FetchedResults&lt;Meal&gt;

    var body: some View {
        VStack {
&#9;   List(meals) { meal in
&#9;&#9;Text(meal.title ?? "Unknown")
&#9;   }
&#9;   Button {
&#9;       let chosenMeal = title.randomElement()!&#9;&#9;
&#9;   } label: {
&#9;&#9;Text("Add Meal")
&#9;   }
&#9;}// VStack
    }
}</code></pre><p>As mentioned earlier, Managed Object Context(MOC) is used to save/delete data from store. So, to use MOC we need to declare it:</p><pre><code><code>@Environment(\\.managedObjectContext) var moc
</code></code></pre><p>Now let&#8217;s try using moc to save the data we declared and selected.</p><pre><code><code>Button {
   let chosenMeal = set.randomElement()
   let meal = Meal(context: moc)
   meal.title = "\\(chosenMeal ?? "Unknown")"
   try? moc.save()
} label: {
   Text("Add Meal")
}
</code></code></pre><p><strong>Special Note</strong>: Each view using moc need to be added to the environment.</p><h2>Filtering core data</h2><p>We have a model entity called Beverage,  which have as attributes title and categories both of type String.</p><p>Step 1: Create the MOC environment in the view</p><pre><code><code>@Environment(\\.managedObjectContext) var moc
</code></code></pre><p>Step 2: Read data from model using fetch request</p><pre><code><code>@FetchRequest(sortDescriptors: [], predicate: nil) var Beverages: FetchedResults&lt;Beverage&gt;
</code></code></pre><p>Step 3: Create view to write data and save to MOC</p><pre><code><code>var body: some View {
    VStack {
&#9;List(Beverages, id:\\.self) { beverage in
&#9;  HStack {
&#9;&#9;Text(beverage.title ?? "Unknown name")
&#9;&#9;  .font(.title3)
&#9;&#9;Spacer()
&#9;&#9;Text(beverage.categories ?? "Unknown")
&#9;&#9;  .font(.body)
&#9;&#9;  .foregroundColor(.gray)
&#9;&#9;&#9;&#9;&#9;
&#9;  }//HStack
&#9;} //List
&#9;Button("Add Examples") {
&#9; let beverage1 = Beverage(context: moc)
&#9;     beverage1.title = "Coffee"
&#9;     beverage1.categories = "Hot"
&#9;&#9;&#9;&#9;
&#9; let beverage2 = Beverage(context: moc)
&#9;     beverage2.title = "Peach QQ"
&#9;     beverage2.categories = "Cold"
&#9;&#9;&#9;&#9;
&#9; let beverage3 = Beverage(context: moc)
&#9;     beverage3.title = "Sprite"
&#9;     beverage3.categories = "Fizzy"
&#9;&#9;&#9;&#9;
&#9; let beverage4 = Beverage(context: moc)
&#9;     beverage4.title = "Water"
&#9;     beverage4.categories = "Room temp"
&#9;&#9;&#9;
            // Save to database&#9;
&#9; try? moc.save()

&#9;}//Button
  }//Vstack
}//body
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S5bS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S5bS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 424w, https://substackcdn.com/image/fetch/$s_!S5bS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 848w, https://substackcdn.com/image/fetch/$s_!S5bS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!S5bS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S5bS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg" width="180" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2070,&quot;width&quot;:1242,&quot;resizeWidth&quot;:180,&quot;bytes&quot;:249785,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S5bS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 424w, https://substackcdn.com/image/fetch/$s_!S5bS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 848w, https://substackcdn.com/image/fetch/$s_!S5bS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!S5bS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e7623dc-ef20-46b8-b0d5-9606563c0887_1242x2070.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">No sorting</figcaption></figure></div><p>Step 4: Learn how to filter data using <em><strong>NSPredicate</strong></em> property wrapper</p><ol><li><p>Filter data where categories = cold</p></li></ol><pre><code><code>@FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "categories == 'Cold'")) var Beverages: FetchedResults&lt;Beverage&gt;
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P8kx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P8kx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 424w, https://substackcdn.com/image/fetch/$s_!P8kx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 848w, https://substackcdn.com/image/fetch/$s_!P8kx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!P8kx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!P8kx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg" width="284" height="469.9033816425121" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ace050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2055,&quot;width&quot;:1242,&quot;resizeWidth&quot;:284,&quot;bytes&quot;:175660,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!P8kx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 424w, https://substackcdn.com/image/fetch/$s_!P8kx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 848w, https://substackcdn.com/image/fetch/$s_!P8kx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!P8kx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Face050a7-48f4-46b9-87a6-ba4993821047_1242x2055.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Filtered data</figcaption></figure></div><ol start="2"><li><p>Filtering data where title = pimm&#8217;s cup</p></li></ol><pre><code><code>@FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "title == 'pimm's'")) var Beverages: FetchedResults&lt;Beverage&gt;
</code></code></pre><p>This results in</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xkdr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xkdr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 424w, https://substackcdn.com/image/fetch/$s_!xkdr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 848w, https://substackcdn.com/image/fetch/$s_!xkdr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 1272w, https://substackcdn.com/image/fetch/$s_!xkdr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xkdr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png" width="863" height="136" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:136,&quot;width&quot;:863,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:44444,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xkdr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 424w, https://substackcdn.com/image/fetch/$s_!xkdr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 848w, https://substackcdn.com/image/fetch/$s_!xkdr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 1272w, https://substackcdn.com/image/fetch/$s_!xkdr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c36c156-b08c-47f2-a69b-b16e83e85ee2_863x136.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><em>WHY THIS ERROR</em>?</p><p>Because there is an <strong>&#8216;</strong> in the beverage&#8217;s name</p><p>To be able to parse string data that contain &#8216; we do it as follows:</p><pre><code><code>@FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "title == %@", "Pimm's Cup")) var Beverages: FetchedResults&lt;Beverage&gt;
</code></code></pre><p>the &#8216;%@&#8217; represents &#8594; whatever the string inserted here and the string inserted here is written as the second argument of NSPredicate</p><p>Price added to attribute so we can provide an example of using comparison operators for sorting</p><pre><code><code>// ... more code here
&#9;beverage1.price = 110&#9;&#9;&#9;
        beverage2.price = 175
&#9;beverage3.price = 30
&#9;beverage4.price = 20
&#9;beverage5.price = 100
&#9;beverage6.price = 275
&#9;beverage7.price = 275
&#9;&#9;&#9;&#9;
// try? moc.save()&#9;&#9;&#9;&#9;
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pioa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pioa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Pioa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Pioa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Pioa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pioa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg" width="270" height="448.9130434782609" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2065,&quot;width&quot;:1242,&quot;resizeWidth&quot;:270,&quot;bytes&quot;:296106,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Pioa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Pioa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Pioa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Pioa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F216f6b33-1248-44ad-9bce-28ca6f241aca_1242x2065.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">No sorting</figcaption></figure></div><ol start="3"><li><p>Sorting beverages whose prices are less and equal to 100</p></li></ol><pre><code>@FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "price &lt;= %@", "100")) var Beverages: FetchedResults&lt;Beverage&gt;</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eZlp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eZlp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 424w, https://substackcdn.com/image/fetch/$s_!eZlp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 848w, https://substackcdn.com/image/fetch/$s_!eZlp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!eZlp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eZlp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg" width="232" height="382.11764705882354" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2016,&quot;width&quot;:1224,&quot;resizeWidth&quot;:232,&quot;bytes&quot;:186623,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eZlp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 424w, https://substackcdn.com/image/fetch/$s_!eZlp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 848w, https://substackcdn.com/image/fetch/$s_!eZlp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!eZlp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c31ea86-9ee9-43db-b931-9b62330359f8_1224x2016.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ol start="4"><li><p>Sorting beverages that can be in different categories</p></li></ol><pre><code><code> @FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "categories IN %@", ["Alcohol based", "Cocktail"])) var Beverages: FetchedResults&lt;Beverage&gt;</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Vxfy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Vxfy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Vxfy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Vxfy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Vxfy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Vxfy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg" width="276" height="459.3235294117647" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2037,&quot;width&quot;:1224,&quot;resizeWidth&quot;:276,&quot;bytes&quot;:181345,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Vxfy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Vxfy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Vxfy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Vxfy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8964b122-ef1a-44ce-8756-4fde58398175_1224x2037.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ol start="5"><li><p>Sorting beverages with title starting with a particular character</p></li></ol><ul><li><p>Case sensitive</p></li></ul><pre><code><code>@FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "title BEGINSWITH %@", "P")) var Beverages: FetchedResults&lt;Beverage&gt;
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-9pS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-9pS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 424w, https://substackcdn.com/image/fetch/$s_!-9pS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 848w, https://substackcdn.com/image/fetch/$s_!-9pS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!-9pS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-9pS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg" width="270" height="453.2608695652174" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2085,&quot;width&quot;:1242,&quot;resizeWidth&quot;:270,&quot;bytes&quot;:209664,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-9pS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 424w, https://substackcdn.com/image/fetch/$s_!-9pS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 848w, https://substackcdn.com/image/fetch/$s_!-9pS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!-9pS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8838b649-f831-467d-ad35-5ba86311b57b_1242x2085.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p> Case insensitive</p></li></ul><pre><code><code>@FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "title BEGINSWITH[c] %@", "c")) var Beverages: FetchedResults&lt;Beverage&gt;
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6sX3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6sX3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 424w, https://substackcdn.com/image/fetch/$s_!6sX3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 848w, https://substackcdn.com/image/fetch/$s_!6sX3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!6sX3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6sX3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg" width="312" height="511.7311475409836" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2001,&quot;width&quot;:1220,&quot;resizeWidth&quot;:312,&quot;bytes&quot;:179957,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6sX3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 424w, https://substackcdn.com/image/fetch/$s_!6sX3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 848w, https://substackcdn.com/image/fetch/$s_!6sX3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!6sX3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87d6313a-cf01-47ac-b579-7b048be905dd_1220x2001.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ol start="6"><li><p>Sorting by title containing case insensitive character c</p></li></ol><pre><code><code>@FetchRequest(sortDescriptors: [], predicate: NSPredicate(format: "title CONTAINS[c] %@", "c")) var Beverages: FetchedResults&lt;Beverage&gt;
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4n19!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4n19!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 424w, https://substackcdn.com/image/fetch/$s_!4n19!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 848w, https://substackcdn.com/image/fetch/$s_!4n19!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!4n19!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4n19!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg" width="292" height="478.90821256038646" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2037,&quot;width&quot;:1242,&quot;resizeWidth&quot;:292,&quot;bytes&quot;:322777,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4n19!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 424w, https://substackcdn.com/image/fetch/$s_!4n19!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 848w, https://substackcdn.com/image/fetch/$s_!4n19!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!4n19!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6743c766-5613-442f-b3e3-faa4f8f3e7a8_1242x2037.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2>Filtering a search bar using FetchRequest</h2><pre><code><code>struct ViewSix: View {
   @State private var searchText = ""
   @Environment(\\.managedObjectContext) var moc
   @FetchRequest(sortDescriptors: []) var beverages: FetchedResults&lt;Beverage&gt;
&#9;
   var body: some View {
     VStack{
&#9;  List {
&#9;    ForEach(beverages) { beverage in
&#9;&#9;Text(beverage.title ?? "" )
&#9;    }
&#9;     .listRowSeparator(.hidden)
&#9; }
           .listStyle(.plain)
     }//Vstack
&#9;.navigationTitle("Beverages")
&#9;.searchable(text: $searchText)
&#9;.onChange(of: searchText, perform: { searchText in
&#9;&#9;&#9;
&#9;    if searchText.isEmpty { 
               print("Empty")
&#9;    } else {
&#9;        beverages.nsPredicate = NSPredicate(format: "title     CONTAINS[c] %@", searchText)
&#9;    }//else
&#9;})//OnChange
  }//body
}//ViewSix
</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Afu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Afu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 424w, https://substackcdn.com/image/fetch/$s_!5Afu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 848w, https://substackcdn.com/image/fetch/$s_!5Afu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!5Afu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Afu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg" width="262" height="453.3317230273752" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2149,&quot;width&quot;:1242,&quot;resizeWidth&quot;:262,&quot;bytes&quot;:357986,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5Afu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 424w, https://substackcdn.com/image/fetch/$s_!5Afu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 848w, https://substackcdn.com/image/fetch/$s_!5Afu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!5Afu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb12c5a2-0a63-4b9c-a5f3-9141accf62b2_1242x2149.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Getting started with Firebase in Swift]]></title><description><![CDATA[Installing firebase through SPM (Swift Package Manager)]]></description><link>https://ruwaydah.substack.com/p/getting-started-with-firebase-in</link><guid isPermaLink="false">https://ruwaydah.substack.com/p/getting-started-with-firebase-in</guid><dc:creator><![CDATA[Ada]]></dc:creator><pubDate>Tue, 10 Jan 2023 19:02:47 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Sxk6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>These simple steps will be your guide to integrating firebase into your swift app.</p><h2>Installation of Firebase</h2><ul><li><p>Go to <a href="https://firebase.google.com/docs/ios/installation-methods">https://firebase.google.com/docs/ios/installation-methods</a></p><ul><li><p>If migrating from a CocoaPods-based project, run&nbsp;pod de-integrate&nbsp;to remove CocoaPods from your Xcode project. The CocoaPods-generated&nbsp;.xcworkspace&nbsp;file can safely be deleted afterward.</p><p><em><strong>If you're adding Firebase to a project for the first time, this step can be ignored.</strong></em></p></li></ul></li><li><p>Copy <a href="https://github.com/firebase/firebase-ios-sdk.git">https://github.com/firebase/firebase-ios-sdk.git</a></p></li><li><p>Click on project name in Xcode</p></li><li><p>Click on Package Dependencies</p></li><li><p>Paste git url and select the appropriate repository</p></li><li><p>Select project. And note down the version of firebase</p><p></p></li></ul><p><strong>Note</strong>: The SPM may take a while to verify the repository</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><ul><li><p><strong>Check the needed/appropriate boxes</strong></p><p>For this app (chat clone app), the following boxes were selected -&gt; FireBaseAuth, FireBaseStorage and FireBaseFirestore.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Sxk6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Sxk6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 424w, https://substackcdn.com/image/fetch/$s_!Sxk6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 848w, https://substackcdn.com/image/fetch/$s_!Sxk6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 1272w, https://substackcdn.com/image/fetch/$s_!Sxk6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Sxk6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png" width="673" height="308" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:308,&quot;width&quot;:673,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:59437,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Sxk6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 424w, https://substackcdn.com/image/fetch/$s_!Sxk6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 848w, https://substackcdn.com/image/fetch/$s_!Sxk6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 1272w, https://substackcdn.com/image/fetch/$s_!Sxk6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d415b3a-fe61-4a4a-a41c-eed32011d8ab_673x308.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p><strong>Select add package, the following must be loading and adding to your project</strong></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gwr5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gwr5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 424w, https://substackcdn.com/image/fetch/$s_!gwr5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 848w, https://substackcdn.com/image/fetch/$s_!gwr5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 1272w, https://substackcdn.com/image/fetch/$s_!gwr5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gwr5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png" width="403" height="259" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/09b7861a-0366-424c-819c-647fe10c145c_403x259.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:259,&quot;width&quot;:403,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:39793,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gwr5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 424w, https://substackcdn.com/image/fetch/$s_!gwr5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 848w, https://substackcdn.com/image/fetch/$s_!gwr5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 1272w, https://substackcdn.com/image/fetch/$s_!gwr5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09b7861a-0366-424c-819c-647fe10c145c_403x259.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Using Firebase in project</h2><ul><li><p>First create your project in firebase console at <a href="http://console.firebase.google.com/">console.firebase.google.com</a></p><p><em>Firechat is the name of this app demo.</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KSsN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KSsN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 424w, https://substackcdn.com/image/fetch/$s_!KSsN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 848w, https://substackcdn.com/image/fetch/$s_!KSsN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 1272w, https://substackcdn.com/image/fetch/$s_!KSsN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KSsN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png" width="704" height="328" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:328,&quot;width&quot;:704,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:49201,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KSsN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 424w, https://substackcdn.com/image/fetch/$s_!KSsN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 848w, https://substackcdn.com/image/fetch/$s_!KSsN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 1272w, https://substackcdn.com/image/fetch/$s_!KSsN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faf0e53-79f1-4c44-bcb8-165667cee0c3_704x328.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li><li><p>Select iOS on the dashboard</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ChJE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ChJE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 424w, https://substackcdn.com/image/fetch/$s_!ChJE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 848w, https://substackcdn.com/image/fetch/$s_!ChJE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 1272w, https://substackcdn.com/image/fetch/$s_!ChJE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ChJE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png" width="418" height="221" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:221,&quot;width&quot;:418,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34880,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ChJE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 424w, https://substackcdn.com/image/fetch/$s_!ChJE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 848w, https://substackcdn.com/image/fetch/$s_!ChJE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 1272w, https://substackcdn.com/image/fetch/$s_!ChJE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6b66b03-993d-4964-856e-ce9e7d94cfa0_418x221.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>Copy the bundle ID of your project (in Xcode)</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RL3J!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RL3J!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 424w, https://substackcdn.com/image/fetch/$s_!RL3J!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 848w, https://substackcdn.com/image/fetch/$s_!RL3J!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 1272w, https://substackcdn.com/image/fetch/$s_!RL3J!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RL3J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png" width="755" height="184" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2670f923-78cb-440d-8079-9c7637cdd703_755x184.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:184,&quot;width&quot;:755,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:72707,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RL3J!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 424w, https://substackcdn.com/image/fetch/$s_!RL3J!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 848w, https://substackcdn.com/image/fetch/$s_!RL3J!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 1272w, https://substackcdn.com/image/fetch/$s_!RL3J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2670f923-78cb-440d-8079-9c7637cdd703_755x184.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>Paste the bundle ID in here</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JtIQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JtIQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 424w, https://substackcdn.com/image/fetch/$s_!JtIQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 848w, https://substackcdn.com/image/fetch/$s_!JtIQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 1272w, https://substackcdn.com/image/fetch/$s_!JtIQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JtIQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png" width="832" height="525" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:525,&quot;width&quot;:832,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:97231,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JtIQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 424w, https://substackcdn.com/image/fetch/$s_!JtIQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 848w, https://substackcdn.com/image/fetch/$s_!JtIQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 1272w, https://substackcdn.com/image/fetch/$s_!JtIQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd519d9-aa8e-4ac5-9f9c-3ff5d2dcd32e_832x525.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li><li><p>Download the config file</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ldzn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ldzn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 424w, https://substackcdn.com/image/fetch/$s_!Ldzn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 848w, https://substackcdn.com/image/fetch/$s_!Ldzn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 1272w, https://substackcdn.com/image/fetch/$s_!Ldzn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ldzn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png" width="791" height="549" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:549,&quot;width&quot;:791,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:73681,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ldzn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 424w, https://substackcdn.com/image/fetch/$s_!Ldzn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 848w, https://substackcdn.com/image/fetch/$s_!Ldzn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 1272w, https://substackcdn.com/image/fetch/$s_!Ldzn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F267ad60d-c231-4f17-9a49-1cd3c1ccfd56_791x549.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div></li><li><p>Drag the file into the project as shown below</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DHs4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DHs4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 424w, https://substackcdn.com/image/fetch/$s_!DHs4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 848w, https://substackcdn.com/image/fetch/$s_!DHs4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 1272w, https://substackcdn.com/image/fetch/$s_!DHs4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DHs4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png" width="225" height="201" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/53eab781-987f-4140-85f8-f34ed6580794_225x201.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:201,&quot;width&quot;:225,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:85341,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DHs4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 424w, https://substackcdn.com/image/fetch/$s_!DHs4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 848w, https://substackcdn.com/image/fetch/$s_!DHs4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 1272w, https://substackcdn.com/image/fetch/$s_!DHs4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53eab781-987f-4140-85f8-f34ed6580794_225x201.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>Step 3 can be ignored as we have already added Firebase through SPM</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4giv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4giv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 424w, https://substackcdn.com/image/fetch/$s_!4giv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 848w, https://substackcdn.com/image/fetch/$s_!4giv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 1272w, https://substackcdn.com/image/fetch/$s_!4giv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4giv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png" width="440" height="206" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:206,&quot;width&quot;:440,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:11507,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4giv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 424w, https://substackcdn.com/image/fetch/$s_!4giv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 848w, https://substackcdn.com/image/fetch/$s_!4giv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 1272w, https://substackcdn.com/image/fetch/$s_!4giv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56ce7986-46f0-4fb2-8c8e-61beb737839e_440x206.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>To initialise the firebase SDK inside the project -&gt; create an init() function</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SeKG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SeKG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 424w, https://substackcdn.com/image/fetch/$s_!SeKG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 848w, https://substackcdn.com/image/fetch/$s_!SeKG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 1272w, https://substackcdn.com/image/fetch/$s_!SeKG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SeKG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png" width="258" height="198" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:198,&quot;width&quot;:258,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:14363,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SeKG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 424w, https://substackcdn.com/image/fetch/$s_!SeKG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 848w, https://substackcdn.com/image/fetch/$s_!SeKG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 1272w, https://substackcdn.com/image/fetch/$s_!SeKG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9229f51-3962-459b-bcc0-caf3ea88b02f_258x198.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h2>Using Firebase Authentication </h2></li></ul><ul><li><p>Select authentication from build and click on Get Started</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GV5b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GV5b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 424w, https://substackcdn.com/image/fetch/$s_!GV5b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 848w, https://substackcdn.com/image/fetch/$s_!GV5b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 1272w, https://substackcdn.com/image/fetch/$s_!GV5b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GV5b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png" width="314" height="416" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e5233858-2a04-476a-b536-dd658da68d97_314x416.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:416,&quot;width&quot;:314,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:81199,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GV5b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 424w, https://substackcdn.com/image/fetch/$s_!GV5b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 848w, https://substackcdn.com/image/fetch/$s_!GV5b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 1272w, https://substackcdn.com/image/fetch/$s_!GV5b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5233858-2a04-476a-b536-dd658da68d97_314x416.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p>Select the type of how you want the user to be authenticated. In the case of this app demo we will be using email/passwords.</p></li><li><p>Click enable for Email/Password</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!smVh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!smVh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 424w, https://substackcdn.com/image/fetch/$s_!smVh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 848w, https://substackcdn.com/image/fetch/$s_!smVh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 1272w, https://substackcdn.com/image/fetch/$s_!smVh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!smVh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png" width="895" height="297" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:297,&quot;width&quot;:895,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:98589,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!smVh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 424w, https://substackcdn.com/image/fetch/$s_!smVh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 848w, https://substackcdn.com/image/fetch/$s_!smVh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 1272w, https://substackcdn.com/image/fetch/$s_!smVh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5d387f1-9906-45d6-bdb0-b07725bf5e05_895x297.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p></li><li><p>Initialise authentication in your app</p><pre><code>import Firebase

class FirebaseManager: NSObject {
    let auth: Auth
    static let shared = FirebaseManager()
    override init() {
        FirebaseApp.configure()
        self.auth = Auth.auth()    
        super.init()
    }
}</code></pre></li></ul><p>Writing the above singleton object, allows us to configure and initialise the firebase sdk once. Initialising the firebase more than one time can result in the app crashing, especially when using previews in Xcode. </p><p>Also, now we can use authentication throughout our app through this firebase manager class. </p><p>For example, to create user we can simply write the following code: </p><pre><code>   FirebaseManager.shared.auth.createUser(withEmail: emailAddress, password: password)</code></pre><p><em>The manager class can contain other configurations of firebase such as firestore.</em></p><p><strong>Note: </strong>we can also install Firestore in a better way.</p><p>Installing firestorm through the SPM makes the project take longer to compile compared to installing the package itself from GitHub which is a precompiled version: <a href="https://github.com/invertase/firestore-ios-sdk-frameworks">https://github.com/invertase/firestore-ios-sdk-frameworks</a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://ruwaydah.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Ada&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>