When building your app it’s essential to think about the way content will be displayed to the user. Separating functionality and logic into different view controllers keeps things clean both for the user and in your codebase. While Apple offers ways to navigate to these view controllers with a UINavigationController or UITabBarController sometimes they don’t quite fit the needs of you app.

In this post I’ll build a simple app that demonstrates how to create a navigation interface. …

Higher order functions are simply functions that operate on other functions by either taking a function as an argument, or returning a function. Swift’s Array type has a few methods that are higher order functions: sorted, map, filter, and reduce. These methods use closures to allow us to pass in functionality that can then determine how we want the method to sort, map, filter, or reduce an array of objects.

In this post I’ll give an example of each of these methods and talk a little bit about how the syntax of the closure can change based on what swift can infer. …

Get ready… closures are a difficult topic. Understanding how closures work and why we need them relies heavily on understanding many other concepts in swift. In this post I’ll break down what closures are using some simple examples and hopefully explain just whats going on.

What is a closure?

From the apple documentation:

Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.

Closures can capture and store references to any constants and variables from the context in which they are defined. This is known as closing over those constants and variables. …

Memory management is a key factor when developing apps. If a program is using a lot of memory it can bog down your device making apps run slowly or even cause crashes. Fortunately as a swift developer you can rely on Automatic Reference Counting (ARC) to keep your apps memory usage minimal. This doesn’t mean you can forget about the memory in your app but it does takes care of most things for you.

Its Important to note that ARC only works when working with classes. …

In this post I’ll go over how to persist image data locally on your phone. My previous post covers getting the camera up and running in your app — check it out here. We will pick up where that post left off and get the pictures we are taking in the app to stick around.


We wont be using core data to store the image data directly but rather the file path to where the image data is stored on your phone. …

Apple provides an couple protocols that make it easy to get the camera on your phone functioning in your app.

For this post I’ll build out a single view application that has three image views. If you click on one of the image views it will bring you to the camera where you can take a picture and save it to that view.

note: In order to test this app you must run it on your phone or tablet because the simulator doesn’t have a camera.

Creating The View Controller

First we will set up a View controller in storyboard with three image views in a stack view then create IBOutlets for the three image views. Make sure each UIImageView has its content mode set to “Aspect Fill” and “Clip To Bounds” is checked off under Drawing. This prevents the images from distorting and expanding past the bounds of the image view. …

In Xcode, Storyboard makes it easy to build out ViewControllers, Views, Buttons, Labels, and much more without writing much code. We can connect these visual elements to our code using IBOutlets and IBActions. While doing this helps making building an app a lot easier it also has its drawbacks.

For starters, using Storyboard abstracts whats going on with each object in code. Knowing how a TableView or ViewController is working as an object is important.

Storyboard also can cause some major issue when using version control such as git. If changes are made to a storyboard by more than one collaborator you will be dealing with the conflicts in the XML file which is a big pain. …

The advanced operators “<<” and “>>” are used in swift to shift the bites in an integer a given number of times. Shifting a bit to the right has the effect of halving the integer while shifting it to the left doubles it. For example:

To understand whats going on with bit shifting, we first need to understand how integers are represented in binary. In this example I will use an Unsigned 8 bit integer to demonstrate how this works. …

When working with data structures (such as a binary tree) it is hugely beneficial to know how to work with them using recursive functions. Using recursion is the key to giving your data structure fast and efficient functionality in place of loops. In this post I’ll give a simple example of how recursive functions work and how it can be used with a binary tree.

What makes a function recursive?

When you write a recursive function you are calling the function within itself until you hit an end point. It is a form of iteration but requires slightly different logic than a typical loop.

Lets look at a super basic example of a loop and a recursive function doing the same thing. …

When you use unit tests you are using code to test your project rather than running the simulator and navigating through the app. Testing is not a necessary practice when developing — but if you have good tests set up it makes building and refactoring your code much safer.

The way that we can test code using code is by comparing a functions result to an expected result. So if we have a function that returns the sum of two integers we can give it parameters that have an expected result. …


Doug Galante

Aspiring Coder with a Fine Arts Degree ~ Making Time for Climbing, Cooking, Video Games, and Sleep.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store