<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aaron Smith on Medium]]></title>
        <description><![CDATA[Stories by Aaron Smith on Medium]]></description>
        <link>https://medium.com/@gngrwzrd?source=rss-75be98de68f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0Wi1GJK8yTXlSRv1sR1CnA.png</url>
            <title>Stories by Aaron Smith on Medium</title>
            <link>https://medium.com/@gngrwzrd?source=rss-75be98de68f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:59:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gngrwzrd/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Synchronous Tests for Your Networking API Client]]></title>
            <link>https://gngrwzrd.medium.com/synchronous-tests-for-your-networking-api-client-91c958b6703a?source=rss-75be98de68f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/91c958b6703a</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[xctest]]></category>
            <dc:creator><![CDATA[Aaron Smith]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 02:29:46 GMT</pubDate>
            <atom:updated>2023-03-20T16:01:44.460Z</atom:updated>
            <content:encoded><![CDATA[<p>Here’s a simple and effective way to write an API client that’s synchronously testable and doesn’t use any frameworks.</p><p><strong>APIClient:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/813d22bd60f03d7c406050aab9a1c1c4/href">https://medium.com/media/813d22bd60f03d7c406050aab9a1c1c4/href</a></iframe><p>The key take away is that during tests, the function never uses a real URLSessionDataTask and instead calls <em>completion</em> or <em>failure</em> depending on the existence of <em>responseData</em> or a <em>responseError</em>. And it calls on the calling thread synchronously.</p><p>A few things to point out:</p><ul><li>This is a basic example and you could easily add support for other HTTP methods, parameters, etc.</li><li>responseData — an optional Data for the response</li><li>responseError — an optional Error for a failed response.</li><li>DeveloperCenter — A class coming up…</li></ul><p><strong>DeveloperCenter:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/466f9455e93667cb836ef9d0bf7368c3/href">https://medium.com/media/466f9455e93667cb836ef9d0bf7368c3/href</a></iframe><p>Developer center just allows us to set a flag that unit testing is happening from a test.</p><p><strong>APIClientExtension:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a4bbec527fc67f8187359143167ece2/href">https://medium.com/media/8a4bbec527fc67f8187359143167ece2/href</a></iframe><p><em>APIClientExtension</em> is where your domain specific api calls live, instead of adding directly into the APIClient. Alternatively you could put concrete api calls into a different class. The goal is to not mix your model objects into the main APIClient.</p><p><strong>MovieViewController:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bc3dc42e7ea86cc0927c889d025046a/href">https://medium.com/media/6bc3dc42e7ea86cc0927c889d025046a/href</a></iframe><p>This is a contrived example to illustrate a <strong><em>synchronous</em></strong> test coming up. There’s one method that retrieves movie data and reloads a fictional table view.</p><p>Also worth mentioning is that storing the <em>error</em> here is merely another contrived example for the sake of demonstrating the test. You could instead show an alert and write a unit test that confirms an alert is shown.</p><p><strong>MovieViewControllerTests:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/375a2c4aeea8432ddbe4d77cf50b8f64/href">https://medium.com/media/375a2c4aeea8432ddbe4d77cf50b8f64/href</a></iframe><p>Finally the tests. One test simply tests success and that there are a specific number of movies in the data source. Another tests failure.</p><p>You might wonder what the benefit is here. Because the networking part of the view controller can now be synchronous while testing, the tests don’t need any expectations or asynchronous considerations. You can test the view controller as if the client either succeeded or failed after the networking code without any asynchronous code!</p><p>Since the environment running is just a test, it doesn’t matter that networking is synchronous.</p><p>I find it better to have simple tests when possible. Avoiding asynchronous as much as possible in tests so the tests read and perform synchronously.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91c958b6703a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Form Field Navigation on iOS with UIKit — Part 2]]></title>
            <link>https://gngrwzrd.medium.com/form-field-navigation-on-ios-with-uikit-part-2-3ea06624a9da?source=rss-75be98de68f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ea06624a9da</guid>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[uitextview]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[uitextfield]]></category>
            <dc:creator><![CDATA[Aaron Smith]]></dc:creator>
            <pubDate>Wed, 02 Jun 2021 19:14:58 GMT</pubDate>
            <atom:updated>2021-06-02T19:14:58.865Z</atom:updated>
            <content:encoded><![CDATA[<h3>Form Field Navigation on iOS with UIKit — Part 2</h3><p>In the previous article I outlined how to navigate between text inputs using this strategy:</p><ul><li>Recursively search all subviews from a parent view to find all UITextField and UITextView instances.</li><li>Sort them by position on screen in window coordinates.</li><li>Use notifications to navigate next, previous, or end editing.</li></ul><p>Let’s continue and take this idea one step further.</p><p>The next addition will be returnKeyType customization. We can set a default value of .next or .done — depending on where the input is in the list — last is set to .done.</p><p>We can take that even one step further by allowing the input delegates to deny updating the returnKeyType, or providing something other than .next or .done.</p><p>Here’s a protocol to provide those settings:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5caecab8ce0ee53f083c518a7da4adbf/href">https://medium.com/media/5caecab8ce0ee53f083c518a7da4adbf/href</a></iframe><p>The protocol above can be implemented by a UITextField.delegate, or UITextView.delegate for more custom control beyond the default .next or .done returnKeyTypes.</p><p>You might wonder why even provide these options? One edge case I ran into was a UITextView that allowed new lines — the return key shouldn’t navigate next, or end editing. That’s where we’d need an input accessory view to add navigation options (Part 3 of this series).</p><p>Now let’s update our class to set the returnKeyType.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d51b21898fb894b3c3ced97ec6d8cf9/href">https://medium.com/media/9d51b21898fb894b3c3ced97ec6d8cf9/href</a></iframe><p>Simple. We now have default behavior for return key types — either .next, or .done when the input is last. We can also define custom behavior by implementing the protocol. Excellent!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ea06624a9da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Form Field Navigation on iOS and UIKit]]></title>
            <link>https://gngrwzrd.medium.com/form-field-navigation-on-ios-and-uikit-6ac9a66cdaa2?source=rss-75be98de68f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac9a66cdaa2</guid>
            <category><![CDATA[uitextfield]]></category>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[uitextview]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Aaron Smith]]></dc:creator>
            <pubDate>Tue, 01 Jun 2021 03:01:01 GMT</pubDate>
            <atom:updated>2021-06-02T17:23:03.146Z</atom:updated>
            <content:encoded><![CDATA[<h3>Form Field Navigation on iOS with UIKit — Part 1</h3><p>Here’s a cool way to handle form field navigation without having to link all of your UITextField and UITextView instances together manually.</p><p>The strategy is this:</p><ul><li>Recursively search all subviews from a parent view to find all UITextField and UITextView instances.</li><li>Sort them by position on screen in window coordinates.</li><li>Use notifications to navigate next, previous, or end editing.</li></ul><p>Let’s start by looking at a basic class that will find all UITextField and UITextView instances from a parent view and then sort them by position.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6a7a7be9780879614e196f7c33bae9b/href">https://medium.com/media/d6a7a7be9780879614e196f7c33bae9b/href</a></iframe><p>Simple. Let’s add navigation capabilities next.</p><p>I chose to use notifications to inform the field navigator it can move next, previous, or be done.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e074e104eb3bf504a49791ccd1b7e4a/href">https://medium.com/media/0e074e104eb3bf504a49791ccd1b7e4a/href</a></iframe><p>Why notifications?</p><p>Views may be nested deeply or in table or collection view cells. Instead of passing around instances of a field navigator; I find it easier to tell the field navigator via notifications when to navigate.</p><p>Why not a singleton?</p><p>Using an instance of a field navigator scopes which fields to navigate through. A singleton would be difficult to use if a view controller with form fields also presented a modal with form fields.</p><p>Here’s the new field navigator with notifications and navigation capabilities.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f55f69c842ddc7f50744f5c75a87db4c/href">https://medium.com/media/f55f69c842ddc7f50744f5c75a87db4c/href</a></iframe><p>There are quite a few new helper methods here that i’ll leave for you to review.</p><p>What else might we add? How about:</p><ul><li>Updating the input’s returnKeyType based on its position in the list.</li><li>Setting a standard inputAccessoryView with navigation buttons.</li><li>Adding protocols with more control over returnKeyType and inputAccessoryView.</li><li>UITableView and UICollectionView considerations.</li></ul><p>In the next post, we’ll add those features and more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac9a66cdaa2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>