CocoaCheerleaders

Hints, tips and code snippets for Swift and SwiftUI. Short, focused, and ready to paste into Xcode.

Latest tips

Join lists naturally, in any language

Turn an array of word into a sentence with the right commas and the right word for "and" or "or", without string joining.

20 November 2026 · Formatting

Format percentages and decimal places

Format percentages, signs, and decimal places with format styles, and let the guest's locale choose the separators.

20 November 2026 · Formatting

Compact big numbers like 1.2K and 3.4M

Show follower counts, views and downloads in short form, with the right abbreviations for each language.

20 November 2026 · Formatting

Automatic plurals with inflect

1 fish, 2 fish—pluralization is weird. A quick way to automatically get grammar-compliant plurals for things other than fish.

18 November 2026 · Text and localization

Format dates with Date.FormatStyle

Ask for the date fields you want and let the locale decide the order, separators and 12 or 24-hour clock. No more dateFormat strings.

18 November 2026 · Formatting

Formatting money

How to format money for the guest's locale: symbol, separators and decimals included.

18 November 2026 · Formatting

"5 minutes ago" and live countdowns

Text can show relative dates and run timers by itself. No Timer, no publishers, no string building.

18 November 2026 · Formatting

All tips

By category

Formatting

Numbers, currency, percentages, dates, relative time, durations, measurements and lists, formatted the right way.

6 tips

Text and localization

AttributedString, Markdown in Text, automatic grammar agreement and string catalogs.

1 tip