<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[AppNation Engineering - Medium]]></title>
        <description><![CDATA[Join the Mission — appnation.co/careers - Medium]]></description>
        <link>https://medium.com/appnation?source=rss----4629c827745d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>AppNation Engineering - Medium</title>
            <link>https://medium.com/appnation?source=rss----4629c827745d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:34:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/appnation" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How To Use Custom Fonts in Your iOS App]]></title>
            <link>https://medium.com/appnation/how-to-use-custom-fonts-in-your-ios-app-24514125b5a3?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/24514125b5a3</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:51:25 GMT</pubDate>
            <atom:updated>2019-11-26T15:43:58.162Z</atom:updated>
            <content:encoded><![CDATA[<h4>Moving beyond the default fonts on your Mac</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uddjHg8BCaKJzwF3" /><figcaption>Photo by <a href="https://unsplash.com/@alex_andrews?utm_source=medium&amp;utm_medium=referral">Alexander Andrews</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>What makes Medium’s design beautiful and simple at the same time? I think it’s the fonts they use. This applies to every app out there. If you’re using beautiful fonts, your apps will look beautiful.</p><p>That’s all you need to know, and so let’s add custom fonts into your app.</p><h3>1. Import Font Files Into Your Project</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*S99hKxigBIrdjNyXiGTjLg.png" /></figure><p>Import .otf or .ttf files of your custom fonts. I created a folder named ‘Font’ to keep everything organized.</p><p>Make sure you set the right target membership for your imported files on Target Inspector.</p><h3>2. Configure Your Info.plist to Use New Fonts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJp9piAUWlIEsWnpkXjinA.png" /></figure><p>Add the Fonts provided by application array and insert your files as strings. Alternatively, you can view the Info.plist file by source code and add the UIAppFonts key into your xml.</p><pre><strong>&lt;key&gt;</strong>UIAppFonts<strong>&lt;/key&gt;<br>  &lt;array&gt;<br>    &lt;string&gt;</strong>Montserrat-Regular.otf<strong>&lt;/string&gt;<br>    &lt;string&gt;</strong>Montserrat-Light.otf<strong>&lt;/string&gt;<br>    &lt;string&gt;</strong>Montserrat-Medium.otf<strong>&lt;/string&gt;<br>    &lt;string&gt;</strong>Montserrat-Bold.otf<strong>&lt;/string&gt;<br>&lt;/array&gt;</strong></pre><h3>3. Create UIFont Extension</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8120db4d9f38931f5df45e08545e4c8c/href">https://medium.com/media/8120db4d9f38931f5df45e08545e4c8c/href</a></iframe><p>Create a new Swift file and define a UIFont extension. We’re just making our lives easier so we don’t have to remember the exact name of our font every time. Most of the time, your apps will use the same font with different sizes and weights, and so this should be enough for simple apps.</p><h3>4. Start Using Your Fonts</h3><p>Let’s say you have a UILabel. Here’s how you should set its font and size.</p><pre><strong>myLabel.font = UIFont.Regular(size: 16)</strong></pre><p>However, as this is creating a UIFont object every time you need it, you probably want to define some font variables depending on your design.</p><p>For example, if you regularly use your font in Regular and font size 16, you should define a font variable and reference to it.</p><pre><strong>let titleFont = UIFont.Regular(size: 16)</strong></pre><p>That’s all! You can call your fonts from anywhere in your app now.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24514125b5a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/how-to-use-custom-fonts-in-your-ios-app-24514125b5a3">How To Use Custom Fonts in Your iOS App</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Build a Today Widget for Your iOS App]]></title>
            <link>https://medium.com/appnation/how-to-build-a-today-widget-for-your-ios-app-741b9ca1c59a?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/741b9ca1c59a</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:51:14 GMT</pubDate>
            <atom:updated>2019-11-14T18:46:48.400Z</atom:updated>
            <content:encoded><![CDATA[<h4>A widget is enough to make people come back to your app more</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lyiwsv5sX13w_OFIh4v9qA.jpeg" /><figcaption>Coinbase Today Widget</figcaption></figure><p>People have so many apps on their phone and this inevitably makes it very difficult for apps to be remembered on a daily basis. The today screen is something most iPhone users view every day, and if you have a place on this screen, your app won’t be forgotten by the user.</p><p>One of my favorite today widgets is Coinbase’s cryptocurrency price widget. If you are interested in cryptocurrencies, this widget makes it very easy to track prices.</p><p>Let’s talk about where to start if you want to build something like this for your app.</p><h3>Add Today Extension Target Into Your Project</h3><p>View your project and click on + to add a new target. Search for<em> Today </em>and select <em>Today Extension</em> to add to your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*pC-3ADmk_eO6Qrs_u1Mqtw.gif" /></figure><p>This will create some files under a<em> </em>folder in your project. TodayViewController is where you will implement everything you need.</p><p>You can treat this view controller as a standard view controller. The only difference will be updating the views and the memory limit you get with this extension.</p><p>Here’s what <a href="https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/Today.html">Apple says about today widgets:</a></p><blockquote>“A Today widget should:</blockquote><blockquote>Ensure that content always looks up to date.</blockquote><blockquote>Respond appropriately to user interactions.</blockquote><blockquote>Perform well (in particular, iOS widgets must use memory wisely or the system may terminate them).”</blockquote><p>The memory limit for the widget is 16 MB, so keep it simple and make sure to test out your widget for memory leaks.</p><h3>Share Data Between Your App and Extension</h3><p>The only way to share data between your app and extension is by using <em>App Group</em>s and <em>UserDefaults</em>.</p><p>First, you will need to add <em>App Group</em> capability to your app target. Click on +<em> Capability</em> button and select <em>App Groups</em>. Click on <em>+</em> and type a name for your group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*JbkZx0UKrCmDXCTpRyyGlQ.gif" /></figure><p>Do the same thing for your today widget target.</p><p>Now, create a file called GroupDataManager.swift to implement the required functions to save, remove, and retrieve data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1e00e162fcc9da39af182ed94953fd9/href">https://medium.com/media/f1e00e162fcc9da39af182ed94953fd9/href</a></iframe><p>Make sure this file is available for both of your targets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*Sdw277AdN0SeHe7qFyI3Bw.png" /><figcaption>GroupDataManager.swift — File Inspector</figcaption></figure><p>Now, go to the view controller in your app and save data to retrieve from your widget.</p><pre> GroupDataManager.shared.saveData(value: “Hello Medium!”, key: “dataKey”)</pre><p>In your TodayViewController.swift of your today widget, retrieve this data by using the retrieve function.</p><pre>let testData = GroupDataManager.shared.retrieveData(key: &quot;dataKey&quot;) <strong>as</strong>? String</pre><p>You can simply display this string in the label to see if everything is working as expected.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5a45db95f63d3f39696a417571da1ec/href">https://medium.com/media/d5a45db95f63d3f39696a417571da1ec/href</a></iframe><p>Now, run your app and add the widget to your today screen to see how it looks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7z622O0mZVga9UneLKft7A.jpeg" /></figure><p>That’s it! You have successfully built a today widget! Now use your imagination to build something useful for your users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=741b9ca1c59a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/how-to-build-a-today-widget-for-your-ios-app-741b9ca1c59a">How To Build a Today Widget for Your iOS App</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Set a Dark Mode App Icon for Your App]]></title>
            <link>https://medium.com/appnation/how-to-set-a-dark-mode-app-icon-for-your-app-cc143d56f100?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/cc143d56f100</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:50:58 GMT</pubDate>
            <atom:updated>2019-11-15T17:42:05.269Z</atom:updated>
            <content:encoded><![CDATA[<h4>We’ve given the rest of our app a dark mode, now let’s set the icon</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tyRrLcD2-BZu3sMiMr6J_g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@bensow?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Benjamin Sow</a> on <a href="https://unsplash.com/s/photos/app-icon?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>If you deeply care about the experience of your apps, you should definitely consider adding dark mode support. Recently, dark mode got even more popular as iOS and Android added a native dark mode into the OS itself.</p><p>With iOS 13, users can now choose if they want to use their phone in dark mode or light mode. This forces all apps to implement dark mode unless they opt out by using overrideUserInterfaceStyle.</p><p>If you’re interested in offering a dark mode for your users, here’s how you can set a different icon.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44db6fdfa27e5be39d1bc95b48037865/href">https://medium.com/media/44db6fdfa27e5be39d1bc95b48037865/href</a></iframe><p>Possibly place this code into your view controller’s viewDidLoad. self.traitCollection.userInterfaceStyle helps us to find out the preferred interface style.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*NE8TkhaE0ddt-hEA9Z-YVQ.png" /><figcaption><em>2x = 120x120, 3x = 180x180</em></figcaption></figure><p>Make sure to import 2x and 3x of your dark mode app icon (<em>2x = 120x120, 3x = 180x180</em>). The app icon files have to be imported into the project. Therefore, you can’t set them programmatically.</p><p>In their <a href="https://developer.apple.com/documentation/uikit/uiapplication/2806818-setalternateiconname">documentation</a>, Apple states that you must declare your app’s primary and alternate icons using the CFBundleIcons key of your app’s Info.plist file.</p><p>Here’s how to configure alternate icons in your Info.plist file.</p><pre>&lt;key&gt;CFBundleIcons&lt;/key&gt;<br>&lt;dict&gt;<br>  &lt;key&gt;CFBundleAlternateIcons&lt;/key&gt;<br>  &lt;dict&gt;<br>  &lt;key&gt;AppIcon-DarkMode&lt;/key&gt;<br>  &lt;dict&gt;<br>     &lt;key&gt;CFBundleIconFiles&lt;/key&gt;<br>     &lt;array&gt;<br>        &lt;string&gt;AppIcon-DarkMode&lt;/string&gt;<br>     &lt;/array&gt;<br>     &lt;key&gt;UIPrerenderedIcon&lt;/key&gt;<br>     &lt;false/&gt;<br>   &lt;/dict&gt;<br>  &lt;/dict&gt;<br>  &lt;key&gt;CFBundlePrimaryIcon&lt;/key&gt;<br>   &lt;dict&gt;<br>      &lt;key&gt;CFBundleIconFiles&lt;/key&gt;<br>   &lt;array&gt;<br>     &lt;string&gt;AppIcon&lt;/string&gt;<br>   &lt;/array&gt;<br>   &lt;key&gt;UIPrerenderedIcon&lt;/key&gt;<br>   &lt;false/&gt;<br>   &lt;/dict&gt;<br>&lt;/dict&gt;</pre><p>That’s it. It’s actually this easy to set a dark mode icon for your app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc143d56f100" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/how-to-set-a-dark-mode-app-icon-for-your-app-cc143d56f100">How To Set a Dark Mode App Icon for Your App</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a UITabBar Controller for Navigation on tvOS]]></title>
            <link>https://medium.com/appnation/build-a-uitabbar-controller-for-navigation-on-tvos-5fbbfb091d9b?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/5fbbfb091d9b</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[apple-tv]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[tvos]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:50:19 GMT</pubDate>
            <atom:updated>2019-11-06T13:34:46.910Z</atom:updated>
            <content:encoded><![CDATA[<h4>A simple way to implement beautiful and efficient navigation for Apple TV apps</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HG_52nPO7nYvB4Pct7oLmw.png" /><figcaption><a href="https://www.google.com/url?sa=i&amp;rct=j&amp;q=&amp;esrc=s&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjB75rU-9PlAhUuy4UKHcRlD2IQjhx6BAgBEAI&amp;url=https%3A%2F%2Fdeveloper.apple.com%2Fdesign%2Fhuman-interface-guidelines%2Ftvos%2Finterface-elements%2Ftab-bars%2F&amp;psig=AOvVaw2WKtapVWOdi-cmqJwlgM3X&amp;ust=1573074054374041">I</a>mage: Apple Developer <a href="https://developer.apple.com/design/human-interface-guidelines/tvos/interface-elements/tab-bars/">https://developer.apple.com/design/human-interface-guidelines/tvos/interface-elements/tab-bars/</a></figcaption></figure><p>Building tvOS apps is so much different than building for iOS, as it requires you to learn about new UI elements.</p><p>Apple is very strict about the quality of the apps on the tvOS App Store. My apps have been rejected many times due to “<a href="https://developer.apple.com/app-store/review/guidelines/#minimum-functionality">minimum functionality</a>” which sometimes just means that your app doesn’t offer the high-quality experience Apple wants its users to have.</p><p>To build great apps for Apple TV, you should stay away from custom controls or UI elements. Remember that users can only control their TV using the Apple TV remote which is a very strange device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UqR_VqePIGf6ULCjybaESg.jpeg" /><figcaption><a href="https://www.google.com/url?sa=i&amp;rct=j&amp;q=&amp;esrc=s&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjri_rH_NPlAhVpAGMBHcUXAZsQjhx6BAgBEAI&amp;url=https%3A%2F%2Fwww.apple.com%2Fca%2Fshop%2Fproduct%2FMQGD2CL%2FA%2Fsiri-remote&amp;psig=AOvVaw172BHuWq1Of8tA5Gg0zEKx&amp;ust=1573074297669427">Siri Remote</a></figcaption></figure><p>The remote has a touch area that lets users change the focus by swiping. tvOS-native elements work great with this behavior, so we should just stick to what Apple provides.</p><p>I started using UITabBarController on all of my Apple TV apps after tvOS 13 where Apple made significant changes to the UITabBar.</p><h4>Before</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJ-Fpei3N1GbkK90awhQdA.jpeg" /><figcaption><a href="https://www.google.com/url?sa=i&amp;rct=j&amp;q=&amp;esrc=s&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwikorKo-tPlAhU2D2MBHcCdBmIQjhx6BAgBEAI&amp;url=https%3A%2F%2Fszifon.com%2F2019%2F10%2F16%2Fsiri-es-apple-tv-tamogatassal-frissult-a-spotify%2F&amp;psig=AOvVaw3JgQS-yNwz6d7KfKWxilBb&amp;ust=1573073644990153">Siri és Apple TV támogatással frissült a Spotify — Szifon.com</a></figcaption></figure><h4>After</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKDpWHTm5Jsw0QtF4Opp6w.jpeg" /><figcaption><a href="https://www.google.com/url?sa=i&amp;rct=j&amp;q=&amp;esrc=s&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwiQ04PG-tPlAhUd6OAKHYnhBdYQjhx6BAgBEAI&amp;url=https%3A%2F%2Fwww.digitaltveurope.com%2F2019%2F10%2F08%2Fspotify-launches-on-apple-tv%2F&amp;psig=AOvVaw3JgQS-yNwz6d7KfKWxilBb&amp;ust=1573073644990153">Spotify launches on Apple TV — Digital TV Europe</a></figcaption></figure><p>As you can see, this is much more modern and changes the look of the whole app.</p><h3>How To Implement This Into Your Apps</h3><p>I don’t use storyboards or interface builder, so my code will be placed right into your AppDelegate.swift file. You can alter the code to work with your way of doing UI.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/857b03aa1b021f6b981cd92c8fa58705/href">https://medium.com/media/857b03aa1b021f6b981cd92c8fa58705/href</a></iframe><p>This example will create three tabs with the same view controller but different background colors. Here’s how it will look when you run the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*tyRuLLStVonrDzAT4DRBxQ.gif" /></figure><p>If you want to learn more about how to stop using interface builder and start building your UI and transitions programmatically without SwiftUI, take a look at <a href="https://medium.com/better-programming/how-to-build-your-user-interface-programatically-without-swiftui-9f0dc52e02bc">my previous article</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fbbfb091d9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/build-a-uitabbar-controller-for-navigation-on-tvos-5fbbfb091d9b">Build a UITabBar Controller for Navigation on tvOS</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Access Wi-Fi SSID on iOS 13 Using Swift]]></title>
            <link>https://medium.com/appnation/how-to-access-wifi-ssid-on-ios-13-using-swift-40c4bba3c81d?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/40c4bba3c81d</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:50:10 GMT</pubDate>
            <atom:updated>2019-11-14T18:45:17.570Z</atom:updated>
            <content:encoded><![CDATA[<h4>Apple’s increasing support of user privacy may have broken some things in your app</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ldcy2wazA2JCQHc1hzmqWg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@bernardhermant?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Bernard Hermant</a> on <a href="https://unsplash.com/s/photos/wifi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>With the release of iOS 13, Apple made a lot of changes to provide better privacy for iOS users. As this is a very hot topic right now, it was expected.</p><p>It’s great that Apple cares about privacy and not letting any developer access whatever they want. However, if you are a developer, this will cause some features in your app to suddenly stopped working.</p><p>The changes in networking was explained in <a href="https://developer.apple.com/videos/play/wwdc2019/713/">WWDC 19 session 713, Advances in Networking, Part 2</a>. However, this is a one-hour session. I will show you what you need to know in three minutes.</p><p>CNCopyCurrentNetworkInfo is used to access Wi-Fi information. Here’s how you can get connected to Wi-Fi’s SSID.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d50b00fbdb498c4fcf12311adf4c6fbf/href">https://medium.com/media/d50b00fbdb498c4fcf12311adf4c6fbf/href</a></iframe><p>Before this change in iOS 13, Apple just let anyone access connected Wi-Fi SSIDs if they had the capability to access Wi-Fi information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntE5GOMgdVWH2d6IUfXbRQ.png" /><figcaption>Tap on + Capability to add Access Wifi Information capability into your target.</figcaption></figure><p>Unfortunately, now you need much more than that.</p><p>You can only access Wifi SSID in these three cases:</p><ul><li>If your app has permission to access the location.</li><li>If your app has an enabled VPN profile.</li><li>If your app is a networking app that uses NEHotspotConfiguration. <em>You will need extra approval from Apple for this case.</em></li></ul><p>If your app doesn’t do any of these, unfortunately, CNCopyCurrentNetworkInfo<strong> </strong>will return nil in iOS 13 and above. This means that whatever features you have that use Wi-Fi SSID will stop working if users update to iOS 13.</p><p>This is good for privacy purposes, but I think it is very limited. The better solution would be to ask the user for permission if they want to share their network information or not. Let people decide, Apple!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40c4bba3c81d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/how-to-access-wifi-ssid-on-ios-13-using-swift-40c4bba3c81d">How To Access Wi-Fi SSID on iOS 13 Using Swift</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to handle JSON responses using JSONDecoder in Swift? — The Most Efficient Way]]></title>
            <link>https://medium.com/appnation/how-to-handle-json-responses-using-jsondecoder-in-swift-the-most-efficient-way-96315b71ed6d?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/96315b71ed6d</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[app-development]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:49:58 GMT</pubDate>
            <atom:updated>2019-10-24T16:49:46.756Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to handle JSON responses using JSONDecoder<strong> in Swift? — The Most Efficient Way</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ErHT6gxik8lArGNDkMLbQA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Pankaj Patel</a> on <a href="https://unsplash.com/s/photos/json?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I have written an article about making <a href="https://medium.com/@yalcinozd/how-to-make-http-api-requests-with-only-using-urlsession-in-swift-2ab6bef44ec5"><strong>HTTP requests using URLSession in Swift</strong></a><strong> </strong>and without explaining how to handle responses it wouldn’t be complete.</p><p>Again, you don’t need any kind of 3rd party library to handle/parse JSON responses. Just go with what Apple provides (<em>They are spending millions to provide you these solutions already</em>). I am strongly against relying on a 3rd party libraries for the critical parts of your app. Yeah, handling API calls and responses is VERY critical part of almost any app.</p><p>From <a href="https://medium.com/@yalcinozd/how-to-make-http-api-requests-with-only-using-urlsession-in-swift-2ab6bef44ec5">the previous article</a>, this was my example of a simple <strong>GET</strong> request using <strong>URLSession</strong>.</p><pre><strong>let</strong> url = URL(string: &quot;api.myplatform.com/endpoint&quot;)!<br>URLSession.shared.dataTask(with: url) { (data, response, error) <strong>in<br>  </strong><em>// response handling</em><br>}.resume()</pre><p>Let’s fill that response handling part now.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ba5f597e46d8a84e75810f26eb84958/href">https://medium.com/media/5ba5f597e46d8a84e75810f26eb84958/href</a></iframe><p>It’s just one line! But it’s not just magic. We are missing the User class as that does most of the job on how to parse this JSON response.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a6f48ba2667619791c386db4f18c94f/href">https://medium.com/media/4a6f48ba2667619791c386db4f18c94f/href</a></iframe><p>We will use <strong>Decodable</strong> protocol in our class. <strong>Decodable</strong> is <a href="https://developer.apple.com/documentation/swift/decodable">a type that can decode itself from an external representation.</a></p><p><strong>Decodable</strong> and <strong>Encodable</strong> actually provides much more than this and you can even have simpler class or struct without the CodingKeys and initilaztion part. Read more about <a href="https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types">Encoding and Decoding Custom Types</a> to learn more.</p><p>Under <strong>CodingKeys</strong> you can provide exact keys that will be returned from the API. You don’t have to provide it if it matches exactly with the property name.</p><p>That’s it! Now you can repeat this flow for each model.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FMAzkuVTtXuCsqtDiFM%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FMAzkuVTtXuCsqtDiFM%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FMAzkuVTtXuCsqtDiFM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/c21768c956d5fa255c4a7d7a89a2255b/href">https://medium.com/media/c21768c956d5fa255c4a7d7a89a2255b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96315b71ed6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/how-to-handle-json-responses-using-jsondecoder-in-swift-the-most-efficient-way-96315b71ed6d">How to handle JSON responses using JSONDecoder in Swift? — The Most Efficient Way</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make HTTP/API requests with only using URLSession in Swift?]]></title>
            <link>https://medium.com/appnation/how-to-make-http-api-requests-with-only-using-urlsession-in-swift-2ab6bef44ec5?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/2ab6bef44ec5</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:49:51 GMT</pubDate>
            <atom:updated>2021-04-10T09:55:39.352Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQfd3LrnRB1ezPYFJpev5w.jpeg" /></figure><p>When it comes to using 3rd party libraries, I think twice and look for native solutions first. This is because whenever I imported a 3rd party library into my project, it made my life harder. I ended up believing that <strong>reinventing the wheel is a better idea</strong> under some circumstances. You might just need a properly working wheel that is just very simple and Ferrari wheels might just be too much for your Corolla.</p><p>First of all, <strong>URLSession</strong> should be enough for any kind of application you are making. <strong>You don’t need Alamofire</strong> or any other 3rd party library. Use them if you are lazy and want to rely on someone else’s project.</p><p><strong>URLSession is already EASY!</strong> Making <strong>GET</strong> requests using <strong>URLSession</strong> is just two lines.</p><pre><strong>let</strong> url = URL(string: &quot;api.myplatform.com/endpoint&quot;)!<br>URLSession.shared.dataTask(with: url) { (data, response, error) <strong>in<br>  </strong>// response handling<br>}.resume()</pre><p>You probably want to make more complicated API calls. Then, you will need to use <strong>URLRequest</strong>. Here’s an example of a <strong>POST request</strong>.</p><pre><strong>let</strong> url = URL(string: &quot;api.myplatform.com/endpoint&quot;)!<br><strong>var</strong> urlRequest = URLRequest(url: url)<br>urlRequest.httpMethod = &quot;POST&quot;<br>urlRequest.addValue(&quot;no-cache&quot;, forHTTPHeaderField: &quot;cache-control&quot;)<br>URLSession.shared.dataTask(with: urlRequest) { (data, response, error) <strong>in<br>  </strong>// response handling<br>}.resume()</pre><p><strong>What if you want to go deeper?</strong> Here’s what I use in my projects to make any kind of API calls. This function generates a <strong>URLRequest</strong> object with given details.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9d5cb336dbb15ad1dd1d0807d156baa/href">https://medium.com/media/f9d5cb336dbb15ad1dd1d0807d156baa/href</a></iframe><p>Use <strong>NSURLComponents</strong> to create your url part by part by providing scheme, host and path. This way you will have more flexibility when making calls to different paths and subdomains.</p><p>Use <strong>URLQueryItem</strong> to generate a query instead of just adding them directly into your url string such as <em>api.myplatform.com/endpoint?name=yalcin. </em>Please don’t do this because this will get messy if you are working with a complex API.</p><p>Set <strong>timeoutInterval</strong> for <strong>URLRequest</strong> and decide if you want to ignore cache data. Setting timeout is very important as your app will get stuck on bad network connections.</p><p>Finally, set <strong>httpMethod</strong> and <strong>httpBody</strong> to finalize your call. Now you can you can call this function to provide your <strong>URLRequest</strong> in your <strong>URLSession</strong>.</p><pre>let urlRequest = buildURLRequest(hostname: &quot;api.myplatform.com&quot;, path: &quot;endpoint&quot;, parameters: [&quot;name&quot;:&quot;yalcin&quot;], body: [:], method: &quot;PUT&quot;)<br>URLSession.shared.dataTask(with: urlRequest) { (data, response, error) <strong>in<br>  </strong>// response handling<br>}.resume()</pre><p>Without showing how to handle responses this article would be incomplete therefore I have written another article about using <a href="https://medium.com/@yalcinozd/how-to-handle-json-responses-using-jsondecoder-in-swift-the-most-efficient-way-96315b71ed6d"><strong>JSONDecoder and Decodable protocol to handle JSON responses.</strong></a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fj6cvcVqIpekW4%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fcars-hit-driverless-j6cvcVqIpekW4&amp;image=http%3A%2F%2Fgiphygifs.s3.amazonaws.com%2Fmedia%2Fj6cvcVqIpekW4%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="291" frameborder="0" scrolling="no"><a href="https://medium.com/media/2075d09479f7186e315badb5ebfbe6a2/href">https://medium.com/media/2075d09479f7186e315badb5ebfbe6a2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ab6bef44ec5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/how-to-make-http-api-requests-with-only-using-urlsession-in-swift-2ab6bef44ec5">How to make HTTP/API requests with only using URLSession in Swift?</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add Siri Support to Your iOS App in Minutes Using Swift]]></title>
            <link>https://medium.com/appnation/add-siri-support-to-your-ios-app-in-minutes-using-swift-86970322286?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/86970322286</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[siri]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:49:40 GMT</pubDate>
            <atom:updated>2019-10-25T00:24:36.674Z</atom:updated>
            <content:encoded><![CDATA[<h4>It’s easy, and it will make your users happy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*650LaOrF6GwD96YxKiBtYQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@fikrirasyid?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Fikri Rasyid</a> on <a href="https://unsplash.com/s/photos/siri?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>It’s interesting that not many apps support Siri even though it’s really easy to add to your app. I created this tutorial for anyone to easily add Siri support and make your users happy by allowing them to use the Shortcuts app to automate their life. Also, Apple likes developers who implement native functionality into their app — maybe you’ll get featured on the App Store after adding the Siri support into your app.</p><p>Open your Xcode project and go to Capabilities under your target. Scroll down to the bottom and enable Siri.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c5uhWW4trvpuUFTYXD7zxg.png" /></figure><p>After enabling Siri, go to the General tab and scroll down to Linked Frameworks and Libraries. Click on the + icon and add Intents.frameworks and IntentsUI.framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VP3clVIMfEgQuWD_Utohlg.png" /></figure><p>After adding the frameworks to your project, open your Info.plist file in your project. You’ll need to add all the actions you want Siri to perform under the NSUserActivityTypes<strong> </strong>dictionary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G5z1CgppkgFIzyfLN3yEwg.png" /></figure><p>In this case, I added ShowNotifications under the NSUserActivityTypes<strong> </strong>dictionary and set the value as [<em>my-app-bundle-id]</em>.actionname.</p><p>Now open your main view controller or the view controller where the Siri action will happen. Import IntentsUI framework.</p><pre><strong>import</strong> IntentsUI</pre><p>In your view controller class, add a function called setupIntentsForSiri.<strong> </strong>CreateNSUserActivity and assign it to your view’s userActivity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1208cdf027c1fe793bec0b3ddeaa7be7/href">https://medium.com/media/1208cdf027c1fe793bec0b3ddeaa7be7/href</a></iframe><p>The process of configuring NSUserActivity is so simple. Set a title, add speech suggestion for the user in userInfo, and finally, use becomeCurrent to activate the action. The Siri shortcuts feature is only available in iOS 12.0 and after, so you will need to add <em>#available</em> if your project target version is under 12.0.</p><p>Now open your AppDelegate.swift file and add this function to trigger an action after the app is opened by Siri.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc45c2a7e6e467f188b9d81363006d83/href">https://medium.com/media/dc45c2a7e6e467f188b9d81363006d83/href</a></iframe><p>After making sure that the received userActivity is the one we want, I triggered NotificationCenter to post a notification, so I can let all my view controllers know that this action has happened and make the changes accordingly. You can do it this way or just grab your rootViewController using the window in your AppDelegate.</p><p>I need to add a Notification listener in my view controller to receive this notification and perform some action.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/120bef8159a5893dad61cebecf2a34e4/href">https://medium.com/media/120bef8159a5893dad61cebecf2a34e4/href</a></iframe><p>We also need to define the displayNotification function. Inside the function, we can perform the action we want to do. It can be anything you want: display a view controller or reload data, etc. I am not going to get into that part because it depends on what you’re implementing.</p><p>The last thing we want to add is the Shortcut view controller, to allow the user to record their voice and add the actual Siri shortcut. To do this, we need to present INUIAddVoiceShortcutViewController<strong> </strong>with the userActivity we created earlier.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf3454860940c1ceb784b07c41619a34/href">https://medium.com/media/bf3454860940c1ceb784b07c41619a34/href</a></iframe><p>You need to call displaySiriShortcutPopup function in your viewDidLoad to test it. However, Apple requires that developers only ask the user to add the Siri shortcut if the user has already performed the action in the app manually.</p><p>Example: If the user is able to order soup in the app, the Siri shortcut pop-up needs to be displayed after they have ordered soup.</p><p>Now test it by speaking to your phone like a crazy person: “Hey Siri… Siri?”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86970322286" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/add-siri-support-to-your-ios-app-in-minutes-using-swift-86970322286">Add Siri Support to Your iOS App in Minutes Using Swift</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Must-Have Books To Start Developing for iOS]]></title>
            <link>https://medium.com/appnation/5-must-have-books-to-start-developing-for-ios-5d526cab6ee8?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/5d526cab6ee8</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios-developer]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[books]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:49:28 GMT</pubDate>
            <atom:updated>2019-10-28T19:52:51.768Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 Must-Read Books To Become an iOS Developer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nM_vT-e73Kn9CN7abczURA.jpeg" /><figcaption><a href="https://www.pexels.com/photo/books-on-bookshelves-1166657/">https://www.pexels.com/photo/books-on-bookshelves-1166657/</a></figcaption></figure><p>You may be a recent computer science graduate or someone who is just interested in building iOS applications without any background in programming. If you are interested in building iOS apps, you probably sohuld have the fundamental knowledge of programming. Therefore, this list contains books that are not mainly focused on iOS or Swift. This list is an all-in-one package to make you a great mobile developer who is focused on iOS Development.</p><h3>1. Clean Code: A Handbook of Agile Software Craftsmanship</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*YH_RL5-31bcJmdNvzqawwA.jpeg" /><figcaption><a href="https://www.amazon.com/dp/0132350882/ref=emc_b_5_t">https://www.amazon.com/dp/0132350882/</a></figcaption></figure><p>This book will help you to understand what is a good code. Before you learn iOS programming, you must become a developer who can write a clean code.</p><p><a href="https://www.amazon.com/dp/0132350882/ref=emc_b_5_t">https://www.amazon.com/dp/0132350882/</a></p><h3>2. The Swift Programming Language</h3><p>After you know how to build a software in any language, you will easily learn the Swift and its syntax using this online book (documentation) which is free and created by Apple.</p><p><a href="https://docs.swift.org/swift-book/">https://docs.swift.org/swift-book/</a></p><h3>3. Swift Programming: The Big Nerd Ranch Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*4_ZOA1WNLVeMYQf0Oo9tPA.jpeg" /><figcaption><a href="https://www.amazon.com/Swift-Programming-Ranch-Guide-Guides/dp/0134398017">https://www.amazon.com/Swift-Programming-Ranch-Guide-Guides/dp/0134398017</a></figcaption></figure><p>If you want detailed explanations with examples rather than just a documentation, this guide is for you.</p><p><a href="https://www.amazon.com/Swift-Programming-Ranch-Guide-Guides/dp/0134398017">https://www.amazon.com/Swift-Programming-Ranch-Guide-Guides/dp/0134398017</a></p><h3>4. Cracking the Coding Interview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/207/1*qGUhnV4XdZLMb3JylprXtw.jpeg" /></figure><p>If you are planning to get a job as an iOS Developer, you want to read this book and complete challenges before you land an interview. You won’t be always only asked to answer iOS or Swift questions in interviews, so keep in mind that you will get a lot of questions related to computer science and this book will help you to answer those.</p><p><a href="https://www.amazon.ca/Cracking-Coding-Interview-Programming-Questions/dp/0984782850">https://www.amazon.ca/Cracking-Coding-Interview-Programming-Questions/dp/0984782850</a></p><h3>5. Head First Design Patterns: A Brain-Friendly Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*Gs04MfKVuLCq_NCpDvF9bg.jpeg" /></figure><p>Design patterns are one of the most important topics in programming because it helps you to use best practices that have been proven to work very well. From complicated projects to simple ones, design patterns will help you to create a better structure for your project.</p><p><a href="https://www.amazon.com/gp/product/0596007124/">https://www.amazon.com/gp/product/0596007124/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d526cab6ee8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/5-must-have-books-to-start-developing-for-ios-5d526cab6ee8">5 Must-Have Books To Start Developing for iOS</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Create a Custom Action for the Center Tab Bar Item]]></title>
            <link>https://medium.com/appnation/how-to-create-a-custom-action-for-center-tab-bar-item-65e3e5cb0519?source=rss----4629c827745d---4</link>
            <guid isPermaLink="false">https://medium.com/p/65e3e5cb0519</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Yalçın Özdemir]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 09:49:15 GMT</pubDate>
            <atom:updated>2019-10-28T00:24:16.212Z</atom:updated>
            <content:encoded><![CDATA[<h4>Call out your app’s most important action</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5JjXqvTdHHvYkDM87cZjDQ.png" /></figure><p>Most apps have a main action, tweet on Twitter, post on Instagram, send money on PayPal, or check-in on Swarm (Foursquare).</p><p>You may be building an app that features a main action like these, so I wanted to write an article about how to create that center action for your app using Swift.</p><p>A main action is something that should be always visible and easily accessible. Therefore, you probably want to place this action at the center of your tab bar or top of your navigation bar.</p><p>In this case, I will show you the most popular one, which is the center action button on a custom tab bar. You can assign an action to your center button, such as a popup view, a camera view controller, or basically anything you want.</p><p>If you want to get to the completed code, just scroll down to the bottom to see my gist.</p><p>Here’s how it’s done step-by-step.</p><h3>1. Create a Custom Tab Bar Controller</h3><p>You will need a custom tab-bar controller to play around with your tab buttons and actions.</p><pre>class CustomTabBarController:  UITabBarController, UITabBarControllerDelegate {</pre><h3>2. Define Your View Controllers</h3><p>Let’s say you have four tabs on your app and you want to have a center action with your action view controller, which is a custom camera view.</p><pre>var homeViewController: HomeViewController!<br>var secondViewController: SecondViewController!<br>var actionViewController: actionViewController!<br>var thirdViewController: ThirdViewController!<br>var fourthViewController: FourthViewController!</pre><pre>override func viewDidLoad(){        <br>  super.viewDidLoad()                   <br>  homeViewController = HomeViewController()<br>  secondViewController = SecondViewController()<br>  actionViewController = ActionViewController()<br>  thirdViewController = ThirdViewController()<br>  fourthViewController = FourthViewController()<br>}</pre><h3>3. Set Tab Bar Item Icons</h3><p>Let’s set some icons for our tab bar to make it look nice first. Always set the selectedImage as well because your users would want to know which tab they are seeing (just like website menus).</p><p>We’ll do this in your viewDidLoad. Also, don’t forget to set your delegate. (You will know why we do that in step 6.)</p><pre>override func viewDidLoad(){<br>   super.viewDidLoad()<br>   self.delegate = self</pre><p>Inside your viewDidLoad function, set your tab bar icons. Before you do that, make sure you have those images in your project as an asset.</p><pre>homeViewController.tabBarItem.image = UIImage(named: &quot;home&quot;)<br>homeViewController.tabBarItem.selectedImage =<br>UIImage(named: &quot;home-selected&quot;)</pre><pre>secondViewController.tabBarItem.image = UIImage(named: &quot;second&quot;)<br>secondViewController.tabBarItem.selectedImage = UIImage(named: &quot;second-selected&quot;)</pre><pre>actionViewController.tabBarItem.image = UIImage(named: &quot;action&quot;)<br>actionViewController.tabBarItem.selectedImage = UIImage(named: &quot;action-selected&quot;)</pre><pre>thirdViewController.tabBarItem.image = UIImage(named: &quot;third&quot;)<br>thirdViewController.tabBarItem.selectedImage = UIImage(named: &quot;third-selected&quot;)</pre><pre>fourthViewController.tabBarItem.image = UIImage(named: &quot;fourth&quot;)<br>fourthViewController.tabBarItem.selectedImage = UIImage(named: &quot;fourth-selected&quot;)</pre><h3>4. Set Tab Bar’s View Controllers</h3><p>You will need to define which view controllers should be placed in your tab bar controller.</p><pre>viewControllers = [homeViewController, secondViewController, actionViewController, thirdViewController, fourthViewController]</pre><h3>5. Remove Tab Bar Titles</h3><p>Most of the apps with a center action button on their tab bar wouldn’t have the titles because titles take up so much space and they don’t look cool. Most of the time, your icons would be enough to explain what that tab represents anyway.</p><p>Right after you define your viewControllers, remove the titles and center your icon.</p><pre>for tabBarItem in tabBar.items! {<br>  tabBarItem.title = &quot;&quot;<br>  tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0)<br>}</pre><h3>6. Set Action for Center Tab</h3><p>To set an action for the center tab, you will need to detect when the user taps on the tab and define the action for something else, instead of showing the view controller as other tabs.</p><p>You need to use the tab bar delegate function shouldSelect to accomplish this.</p><pre>//MARK: UITabbar Delegate</pre><pre>func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -&gt; Bool {</pre><pre>  if viewController.isKind(of: ActionViewController.self) {<br>     let vc =  ActionViewController()<br>     vc.modalPresentationStyle = .overFullScreen<br>     self.present(vc, animated: true, completion: nil)<br>     return false<br>  }<br>  return true</pre><pre>}</pre><p>Here, we check if the selected tab is the one we defined as an action view controller and if it is, does what we want.</p><p>In this example, I still showed the action view controller, but in a full-screen format where the user would feel as if a whole new part of the app is presented.</p><p>You can do different kinds of things and you don’t even have to present a view controller set for the tab bar controller. As long as you return false in your shouldSelect delegate function, the view controller won’t be shown.</p><p>Here’s the complete code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03f724061c086b2ae66caa4dd5fa1608/href">https://medium.com/media/03f724061c086b2ae66caa4dd5fa1608/href</a></iframe><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65e3e5cb0519" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appnation/how-to-create-a-custom-action-for-center-tab-bar-item-65e3e5cb0519">How To Create a Custom Action for the Center Tab Bar Item</a> was originally published in <a href="https://medium.com/appnation">AppNation Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>