Member-only story

Breaking Down String Format Specifiers in Swift

Format it well!

Steven Curtis
3 min readSep 27, 2022
Photo by Sigmund on Unsplash

Before we start

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 12.2, and Swift 5.3

Prerequisites:

You will be expected to be able to run and use Swift’s Playgrounds

Keywords and Terminology:

String Format Specifiers: This article summarises the format specifiers supported by string formatting methods and functions.

Apple already have a Strings Programming guide for String Format Specifiers, but how are these actually used? In steps this guide

Common formatting

%d, %D

$d and %D represent a signed 32-bit Integer, that is an Int.

In the most basic case we can use the initializer for String to format the Integer

Interpolate with %d

let basicNumber: Int =…

--

--

Responses (1)