Take a look at my old standbys

Laptop and coffee on table
Laptop and coffee on table

Whenever I start a new iOS Swift project, the first thing I do is import my Utilities and Extension files. They help me make my programming more efficient. Let’s have a look at my six favorite and most essential extensions.

1. Dropping Shadow Under UIView

When implementing modern designs, dropping a shadow under a UIView is often required. Instead of having to write multiple lines of code for each view, I use an extension:

Of course, every project might require some minor changes to the shadow style, but that can be changed in a central place.

and reduce the number of tedious tasks on the side

1. Properly maintain and use your extension files

Over time, every developer starts to collect and build a powerful repertoire of extensions and helper functions, that are seamlessly integrated into our workflow. These can include an extension for JSON’s, Dates, logs, UI (for example shadows), haptic feedback, or localization. Read my top 6 Swift Extensions here

Now, how do you get those extension files into every single project of yours, and how to maintain them? I use a simple trick called Git Submodules. This allows me to maintain my helper functions and extensions in a separate Git and pull them into every one of my projects. …

Behold, the almighty weapon to efficiency and data persistence for runtime data and singular information

This is Max (let’s call him Max). Max is our Singleton Class. Max is unique and only exists one. This means, if you tell Max a secret, he will give it back to you correctly if you ask him later. This article is split into two sections. First, we will look at how to create and use Singleton Classes in Swift, and second, we will look at some use cases and scenarios, where I use Singleton Classes.

Let’s create a Max Manager Singleton Class:

class ManagerMax {    public static let shared = ManagerMax()}

That’s it, thanks for reading! #justkidding

Using Git Submodules to maintain code in multiple XCode projects

There are many use cases in which we want to share code between different XCode projects. In an earlier article, I wrote about the power of helper collections and the reasons why those should be shared using git submodules. This article will focus on the technical how-to of maintaining git code inside an existing git repository.

First: Create a Git Repository for your helper functions

To get started, you will need a git repo that contains some of your helper functions. This is how this could look like:

What is it and how to integrate it?

With iOS 14.5, Apple introduced a new framework called App Tracking Transparency (ATT). This new framework replaces the previous LAT mechanism (Limit Ad Tracking), which allowed users to limit their unique identifier to be passed along for ad tracking. While the LAT was set globally in settings, the ATT is applied to every app and device. It works similarly to asking the user for the location or push notification permission.

What ATT does is limit the developers' access to the IDFA (Identifier for Advertisers) keys. This key is used to track users across different apps and browsers, so it is…

… and how you can build a robust app that handles every case of bad data

How many of you have had their app crash because of unwrapping an empty optional value? Let’s look at the favorite line of error message for every Swift newbie:

Fatal error: Unexpectedly found nil while unwrapping an Optional value

Yip, that’s the one. So let’s start by looking into this error message and then look into the safest way not to get burned. If you have a good understanding of the error message above, you can skip through to the second half of the article.

#1 Found nil while unwrapping an Optional value

For a newbie, this phrasing can be awfully hieroglyphic, I know that from personal experience…

Taking your popover controllers to the next level in less than 5 minutes

Adding animations to your app can be a difference between appearing basic or professional. For this example, we will be using the following ready-made Design Block.

But you can create a new ViewController from scratch; learn how-to here:

#1 Open the ViewController

The first step is to open the ViewController. The XIB we will be using in this example is called RateMeViewController and to open it, we run:

let vc = RateMeViewController(nibName: "RateMeViewController", bundle: nil)//
// Make changes to vc (for example to modalPresentationStyle)
self.present(vc, animated: true)

This would open the ViewController without any fancy animations, but we want moooore. So, to…

Modularizing UI elements in your Xcode project

When projects grow, it becomes handy to modularize not only your code but also your UI elements. For this modularization, Apple provides an easy way to create a UI Controller and a XIB (neXt Interface Builder) in one.

#1 Create UI Controller and XIB

Once you decided on a type of UI Controller (View, TableView, CollectionView, etc.), go into File > New > File (⌘N) and select Cocoa Touch Class .

Using closures and finally getting a grip on your asynchronous API calls or database queries

Anytime an iOS app requires some asynchronous data fetching, like API’s or database queries, we need a completion handler, telling us when the data is ready to use. Swift has a completion handler included, so in most cases, there is no need for any third-party libraries like PromiseKit. So let’s get started.

#1 The void completion handler

First, let’s look at a completion handler that returns nothing, except telling us, “It’s done”.

func querySomething(completion: @escaping () -> Void) { 
//do something asynchronous (or synchronous, doesn't matter)

So, do use this function, we call it (like we would any other):

querySomething(completion: {…

In apps, developers often require certain information at different points inside the app. To ask for this information, we need to generate a layover and trigger it from wherever in the application we are.

The input layover will consist of 3 main elements. A title, a subtitle, and the actual phone number input field (you can change this to any input field you require, the user's height, email address, etc.). To trigger the layover, we create two buttons to save the input and give the user the option to delay the information (Do it later).

#1 Create a new UIViewController with a XIB

First, we create ourselves a…

Mats Bauer

Mobile application developer and health enthusiast from Hamburg

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