Your Friendly iOS Coder

Dabby [ダビー]

AnyEncodable: Encoding Unknown Types

The Swift Encodable protocol provides a means for us to encode our custom types into JSON. It is possible to encode into other formats like XML, but this post focuses only on JSON encoding.

Debouncing

When building User interfaces for mobile, we constantly have to juggle responsiveness of the app and actual work that needs to be performed as a result of a particular user interaction. An example of this is a search functionality that queries a remote server, and displays the results in a table view. In this post, we will use the concept of a debouncer to keep the app responsive, while ensuring that we make as few requests as required to retrieve up to date search results for the user.

Adjusting to Keyboard Presentations Modularly

When creating an app that requires information from a user, chances are you use one or more textfields. If we have multiple fields embedded in a scroll view, we want to ensure that the contents of the scroll view do not become inaccessible when the system keyboard is displayed for the user to fill out a field. In this post, we investigate how to handle keyboard presentations in a modular way.

Ensuring Thread-safety Using GCD

When multiple operations that modify a shared resource are performed concurrently, there is always a risk of losing data integrity. In this post, we are going to create a means of ensuring thread-safety using Grand Central Dispatch (GCD).

Resizable FormSheet Modals

Last week, I needed to implement a resizing functionality for a modal displayed on iPad using the formSheet modal presentation style. Basically, We had a navigation controller presented modally, and needed a way to expand the modal to fill the screen or remain the default formSheet size based on what View Controller was being displayed.

Protocols: The Good, the Nice, and the Weird

Over the past few weeks, I have been doing some work involving rewriting a ton of obj-c code into swift. Ever since I watched the WWDC video on Protocol Oriented Programming, using protocols and value types (a.k.a structs) in place of classes has always been my go to. This week I encountered an interesting problem that spawned as a result of entangling protocols (which, in my opinion, were designed to provide functionality mainly for value types) with class inheritance. Before I get deeper into my observations, It might be a good time to give an intro to protocols.