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.

Introduction to Swift 5.5's native async method handler and how it can take out the complexity of your asynchronous components

WWDC 2021 has come and gone and brought some cool features to both iOS and Swift. And sadly, no new Macbook Pro. For one update with the new Swift (5.5), I wanted to take a closer look at the new async handler support. As posted in this previous post, writing asynchronous functions in Swift was tedious. So let’s look at an asynchronous function to get the sum of two integers:

public func sum(a: Int, b: Int, completion: @escaping(Int) -> Void){
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: {
completion(a + b)

So, this function takes a and b as integers…

How the pandemic brings people to their financial limits in fear of missing out

The pandemic brought many changes to our daily lives, whether wearing masks in the supermarket, keeping a 1,5m distance from other people, or working from home. As the advantages of living in the city diminished, with restaurants, bars, and public locations closing down, people went looking for their patch of land to regain the freedom lost during the lockdown. And as of spring 2021, it seems people are willing to pay close to anything. An average house in a radius of 30km around Hamburg (that’s 140qm (1500 square feet)) sets you back around $920,000. Prices in the city go into…

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 .

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