Swift Documentation Quick Guide

If you are a long time Objective-C developer you will be familiar with tools like HeaderDoc to annotate and create HTML documentation from your source code. Xcode Quick Help also displays the output during symbol completion. For Swift code Apple dropped HeaderDoc and switched to a Markdown style syntax. They chose the CommonMark variant of Markdown with some Swift specific keyword extensions. This quick guide covers what you need to know. Read On →

Adapting Images for Size Classes

I was lazy with my last post on how to use auto layout for proportional spacing. I started with three images in a horizontal row that were 120x120 points in size. Unfortunately that is too large to fit on a skinny device like the iPhone 4S. Rather than getting side-tracked with making the images adaptive I just used smaller images. That makes it fit on the smaller devices but wastes a lot of screen space on a larger iPad. Read On →

Proportional Spacing with Auto Layout

Auto Layout is a challenging topic to master. Stack Views and layout anchors introduced in iOS 9 help but it can still be difficult to see how to create certain layouts. In this post I want to look at a common situation where you need to position views at fixed proportions along an axis. It may not be obvious but that can be easily done using center alignments with a multiplier. Read On →

Swift Named Parameters

The rules for naming parameters in Swift functions and methods have changed for the better over the last few releases but still seem to cause confusion. Here is my quick summary updated for Swift 2.1. External vs Local Names The key to understanding parameter names in Swift is to remember that parameter names can have both an external and a local name: Local parameter names are used in the body of the function/method External parameter names are used when calling the function/method. Read On →

Using nullable to annotate Objective-C code

If you have tried and tested Objective-C code you do not need to rewrite it to use it in a Swift project. Unfortunately unless you take some extra steps the resulting Swift interface will treat all Objective-C references as implicitly unwrapped optionals. All those “!” symbols make for some ugly and unsafe Swift code. Fortunately there is a quick fix if you annotate your Objective-C header file with nullable and nonnull. Read On →
No time to watch WWDC videos?

Sign up to get my iOS posts direct to your inbox and I will send you a free PDF of my iOS Size Classes Cheat Sheet.

Unsubscribe at any time.